Skip to content

Instantly share code, notes, and snippets.

@sirlancelot
Last active April 8, 2021 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirlancelot/4f5a5214a74858376c296880a4a23f48 to your computer and use it in GitHub Desktop.
Save sirlancelot/4f5a5214a74858376c296880a4a23f48 to your computer and use it in GitHub Desktop.
Starter ESLint config
const IS_PROD = process.env.NODE_ENV === "production"
/** @type {import("prettier").Options} */
const prettierRc = {
arrowParens: "always",
endOfLine: "lf",
quoteProps: "consistent",
semi: false,
trailingComma: "es5",
}
/** @type {import("eslint").Linter.BaseConfig} */
module.exports = {
root: true,
env: { node: true },
extends: ["plugin:vue/recommended", "eslint:recommended", "@vue/prettier"],
parserOptions: {
parser: "babel-eslint",
},
rules: {
"complexity": ["warn", { max: 6 }],
"max-depth": ["warn", { max: 2 }],
"max-nested-callbacks": ["warn", { max: 2 }],
"max-params": ["warn", { max: 3 }],
"no-console": IS_PROD ? "error" : "off",
"no-debugger": IS_PROD ? "error" : "off",
"prettier/prettier": ["error", prettierRc],
"vue/component-tags-order": "off",
"vue/valid-v-slot": "off", // See vuejs/eslint-plugin-vue#1229
},
overrides: [
{
files: [
"**/__tests__/*.{j,t}s?(x)",
"tests/unit/setup.js",
"tests/unit/**/*.spec.{j,t}s?(x)",
],
env: {
mocha: true,
},
rules: {
"max-nested-callbacks": "off",
"import/no-extraneous-dependencies": "off",
},
},
{
files: "src/lang/*.js",
excludedFiles: "src/lang/index.js",
rules: {
"no-irregular-whitespace": "off",
"prettier/prettier": ["error", { ...prettierRc, printWidth: 999 }],
},
},
],
}
{
"editor.codeActionsOnSave": [
"source.fixAll.eslint",
],
"editor.insertSpaces": true,
"editor.renderWhitespace": "boundary",
"editor.rulers": [80],
"editor.tabSize": 2,
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"javascript.preferences.importModuleSpecifierEnding": "js",
"search.exclude": {
".nyc_output": true,
"coverage": true,
"dist": true,
},
}
{
"scripts": {
"lint": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
},
"devDependencies": {
"@vue/cli-plugin-eslint": "3.5.1",
"@vue/eslint-config-prettier": "4.0.1",
"eslint": "7.20.0",
"eslint-plugin-prettier": "3.3.1",
"eslint-plugin-vue": "7.6.0",
"prettier": "2.2.1",
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment