Usuário:Saul/eslint

From Organic Design
Jump to: navigation, search

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
	}
};