eslint quick start

configuring eslint

  • configuration comments // eslint-disable-next-line prefer-const
  • configuration files .eslintrc.* 可以存放在HOME目录下,就不用每个项目都配置该文件。
  • package.json eslintConfig

configuration file format & priority

  1. .eslintrc.js
  2. .eslintrc.yaml
  3. .eslintrc.yml
  4. .eslintrc.json
  5. .eslintrc deprecated
  6. package.json

ignoring files and directory

# omit all .js file
**/*.js 
# Ignore built files except build/index.js
build/*
!build/index.js

eslintrc

  • env
    'env': {
        'browser': true,
        // new ES6 global variables,
        'es6': true,
        'node': true
    },
  • options
'extends': 'eslint:recommended', // 'airbnb-base' 'standard'
    
  • parseOptions
    'parserOptions': {
        // supporting ES6 syntax 
        'ecmaVersion': 6,
        'sourceType': 'module'
    },
  • plugins
"html"
  • rules
"indent": [
    "error",
    "tab"
],
"linebreak-style": [
    "error",
    "unix"
],
"quotes": [
    "error",
    "single"
],
"semi": [
    "error",
    "always"
]
上一篇:数据结构排序之快速排序(quick sort)


下一篇:GEE学习笔记 六十二:保密是头等大事