The company recently introduced the VUE framework, followed the video to learn the ESLint configuration rules, especially the use of the project configuration and combined with online materials to do the collating, as notes, parallel hope to help others.

Eslint configuration files

[1] Check code validity (JavaScript, JSX, ES6, Html, JSDoc, Posts, Vue, React, AngularJS, React Native, Mocha)

[2] Code formatting (as specified in the ESLint configuration file)

Eslint Reference documentation

[1] English Edition: eslint.org/docs/user-g…

[2] Chinese Version: eslint.cn/docs/rules/

Iii. Other standard reference Documents:

[1] Standard JS syntax rules: github.com/feross/stan…

[2] Import plugin rules :github.com/benmosher/e…

Iv. Other reference documents (thanks here) :

[1]rule Example of a common rule: blog.csdn.net/weixin_3860…

[2] eslint configuration details: blog.csdn.net/q3254421/ar…

5.

module.exports = {

Root: true, // Specify the configuration file root directory: indicates that the current file is the root configuration file of ESLint. You do not need to search for the file directory at the next level

Parser: ‘babel-eslint’,// Specifies an ESLint parser: babel-eslint is a wrapper around the Babel parser making it compatible with ESLint; Possible values are espree and esprima

ParserOptions: {// ESLint parses configuration items

SourceType: “module”,// Specify the js import method, module means import through the module, default is script(means import through the script tag)

    },

Env: {// Run environment and office global variables

Browser: true, // browser environment

    },

Plugins: [// provide plugins

‘HTML’ // Plugin name, omitting the [eslint-plugin-] prefix to denote canonical HTML

].

Extends: ‘airbnb-base’, // Rule inheritance: Airbnb-base extends: ‘airbnb-base’, // Rule inheritance: Airbnb-base includes JS, Es6 syntax checks that rely on [eslint-pugin-import]; Another value, standard, indicates the use of standard JS syntax rules

Settings: {// Add a share rule parameter. This parameter is provided for each rule, but is not used by the rule

        ‘import/resolver’: {

Webpack: {/ / parsing webpack configuration items, the path to bulid/webpack base. Conf., js

                  config: ‘bulid/webpack.base.conf.js’

              }

       }

    },

/* Custom rules

* Single-rule syntax: “rule name “:[rule value, rule configuration] or” rule name “: value

* Basic rule value: OFF /0: Close the rule (do not meet the rule will not remind or throw exceptions); Warn /1: Enable warning rules (code will not be affected if the rules are not met); Error /2: Enable error rules (exit code if the rules are not met)

* /

Rule: {// Specify a rule

/* XXX/AAA: indicates the rule defined by XXX plug-in, omitting the [eslint-plugin] prefix */

‘import/extension’: [‘error’,’always’,{// is the [eslint-plugin-import] custom rule

              js: ‘never’,

             vue: ‘never’,

}].

       ‘import/no-extraneous-dependencies’: [‘error’,{

             optionalDependencies:[‘test/unit/index.js’]

}].

‘no-debugger’: process.env.NODE_ENV === ‘production’ ? 2:0, // Disable the debug mode in the production environment

‘no-empty’: 2, // disallow empty blocks

‘generator-start-spacing’: 0, // spacing before and after generator function *

‘indent’: 0, // indent configuration, 0 means to use the formatting indent that comes with the editor

‘semi’: [‘error’,’always’], // statement enforces semicolons, otherwise an error is reported

‘space-before-function-parent’: 0, // no space needed between function and ()

       }

   }

 

Reprinted from: [eslintrc js configuration files, and reference documentation] (blog.csdn.net/houniao1314…).