Difference between revisions of "User:Saul/eslint"
From Organic Design wiki
m |
m |
||
Line 29: | Line 29: | ||
semi: ["error", "always"], | semi: ["error", "always"], | ||
// allow tabs | // allow tabs | ||
− | no-tabs: [0], | + | "no-tabs": [0], |
// use tab indentation | // use tab indentation | ||
indent: ["error", "tab"], | indent: ["error", "tab"], | ||
// allow paren-less arrow functions | // allow paren-less arrow functions | ||
− | arrow-parens: 0, | + | "arrow-parens": 0, |
// allow async-await | // allow async-await | ||
generator-star-spacing: 0, | generator-star-spacing: 0, | ||
// allow debugger during development | // allow debugger during development | ||
− | no-debugger: process.env.NODE_ENV === "production" ? 2 : 0 | + | "no-debugger": process.env.NODE_ENV === "production" ? 2 : 0 |
} | } | ||
}; | }; | ||
</source> | </source> |
Revision as of 21:42, 11 October 2018
Linting is a way to ensure your code follows convention.
There is a package for the text editor atom (atom.io) that intergrates linting, the package is called: "linter-eslint"
The linting config file is stored as ".eslintrc.js"
Here are the dependencies needed for linting vue:
npm i -D babel-eslint eslint eslint-config-standard eslint-plugin-html eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard
Here is the rule set I like to use:
module.exports = {
root: true,
parser: "babel-eslint",
parserOptions: {
sourceType: "module"
},
env: {
browser: true,
},
// https://github.com/standard/standard/blob/master/docs/RULES-en.md
extends: "standard",
// required to lint *.vue files
plugins: [
"html"
],
rules: {
// disallow single quotes
quotes: ["error", "double"],
// force semi-colons
semi: ["error", "always"],
// allow tabs
"no-tabs": [0],
// use tab indentation
indent: ["error", "tab"],
// allow paren-less arrow functions
"arrow-parens": 0,
// allow async-await
generator-star-spacing: 0,
// allow debugger during development
"no-debugger": process.env.NODE_ENV === "production" ? 2 : 0
}
};