Git Product home page Git Product logo

headless's Introduction

Headless Chrome & Eslint

Headless Chrome

Startup

  • 安装无头浏览器Node开发包

    yarn add puppeteer --dev
  • 编写脚本代码

    const browser = await puppeteer.launch({ ...options })
    const page = await browser.newPage();
    // some actions
    await browser.close()

Reference

Puppeteer on Github

Puppeteer API

Eslint

Startup

  • 安装lint环境

    yarn add babel-core babel-eslint eslint --dev
  • 初始化约束规则

    ./node_modules/.bin/eslint --init

    回答问题即可

  • 配置约束规则

    package.json

    {
        "scripts": {
            "lint": "eslint ."
        }
    }

    .eslintrc.yml

    env:
      es6: true
      node: true
    extends: 'eslint:recommended'
    parser: babel-eslint
    parserOptions:
      sourceType: module
      globalReturn: false
      impliedStrict: true
    rules:
      indent:
        - error
        - 4
      linebreak-style:
        - error
        - unix
      quotes:
        - error
        - single 
      semi:
        - error
        - never
      no-console: off
    • "off" or 0 - turn the rule off
    • "warn" or 1 - turn the rule on as a warning (doesn’t affect exit code)
    • "error" or 2 - turn the rule on as an error (exit code will be 1)
  • 运行约束检查

    yarn lint

Reference

Eslint on Github

Eslint

End

Enjoy coding

headless's People

Contributors

wellerqu avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.