.eslintrc.json Installation Configuration Recipes

MD
R
Markdown

RunCommand files Some basic rules before activating this eslint linter config: - 4 Spaces - NodeJS > 4.x - ES6 features - CommonJS module pattern

Node.js 14 & Typescript

{
  "env": {
    "es2021": true,
    "node": true
  },
  "extends": ["standard"],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 12,
    "sourceType": "module"
  },
	"ignorePatterns": ["*.d.ts", "deprecated.ts"],
  "plugins": ["@typescript-eslint"],
  "rules": {
    // note you must disable the base rule as it can report incorrect errors
    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": ["warn"],
		"no-null/no-null": "off",
    "no-trailing-spaces": "warn",
		"no-useless-return": "warn",
    "no-var": "warn",
    "prefer-const": "warn",
    "quotes": "warn",
    "semi": "off",
		"eol-last": "warn",
		"comma-dangle": "warn",
		"no-undef": "warn",
		"space-before-function-paren": "warn",
		"import/first": "warn",
		"no-useless-constructor": "warn",
		"object-curly-spacing": "warn",
		"eqeqeq": "warn",
		"no-prototype-builtins": "warn",
		"no-unneeded-ternary": "warn",
		"array-callback-return": "warn",
		"import/no-duplicates": "warn",
		"lines-between-class-members": "warn",
		"camelcase": "warn",
		"dot-notation": "warn",
		"prefer-promise-reject-errors": "warn",
		"no-unused-expressions": "warn",
		"no-async-promise-executor": "warn",
		"padded-blocks": "warn",
		"space-in-parens": "warn",
		"node/no-deprecated-api": "warn",
		"no-unreachable": "warn",
		"no-empty": "warn",
		"no-use-before-define": "warn",
		"no-redeclare": "warn",
		"no-multiple-empty-lines": "warn",
		"no-array-constructor": "warn",
		"prefer-regex-literals":"warn",
		"no-useless-catch": "warn",
		"indent": "warn",
		"node/handle-callback-err": "warn",
		"spaced-comment":"warn",
		"no-throw-literal": "warn",
		"one-var": "warn",
		"no-useless-escape": "warn",
		"no-new": "warn",
		"no-multi-spaces": "warn",
		"no-case-declarations": "warn"
  }
}

React Apps

{
  "parserOptions": {
    "ecmaVersion": 7,
    "sourceType": "module",
    "ecmaFeatures": {
        "jsx": true
    }
  }
}

# ########################################################

AirBnB Relaxed

{ "extends": ["airbnb-base"], "rules": { "indent": [2, 2], "no-cond-assign": [2, "except-parens"], "radix": 0, "space-infix-ops": 0, "no-unused-vars": [1, {"vars": "local", "args": "none"}], "default-case": 0, "no-else-return": 0, "no-param-reassign": 0, "quotes": 0, "space-before-blocks":0, "comma-dangle": 0, "no-shadow":1, "no-spaced-func":0, "func-call-spacing":0, "quote-props":0, "function-paren-newline":0 } }

ReactJS Web App

{ "parser": "babel-eslint", "extends": "tamia/react", "env": { "browser": true, "node": true }, "plugins": [ "compat", "es5", "import" ], "settings": { "import/resolver": { "node": { "moduleDirectory": ["src", "node_modules"] } } }, "rules": { "compat/compat": "error", "import/no-unresolved": ["error", { "commonjs": true, "caseSensitive": true }], "import/export": "error", "import/no-named-as-default-member": "error", "import/no-mutable-exports": "error", "import/no-amd": "error", "import/first": ["error", "absolute-first"], "import/no-duplicates": "error", "import/extensions": ["error", "always", { "js": "never" }], "import/no-extraneous-dependencies": "error", "import/newline-after-import": "error", "import/prefer-default-export": "error", "import/no-named-default": "error" }, "globals": { "System": false, "classes": false, "shallow": false, "render": false, "mount": false } }

ESLint for Node with Promises policy enforcement

{ "extends": ["airbnb-base"], "env":{ "node": true }, "plugins": ["promise"], "rules": { "promise/catch-or-return": 2, "promise/no-return-wrap": 2, "promise/no-nesting": 1, "promise/param-names": 2, "promise/always-return": 1, "no-cond-assign": [2, "except-parens"], "radix": 0, "space-infix-ops": 0, "no-unused-vars": [1, {"vars": "local", "args": "none"}], "default-case": 0, "no-else-return": 0, "no-param-reassign": 0, "quotes": 0, "space-before-blocks":0, "array-callback-return":1, "consistent-return":1, "arrow-parens": 0, "comma-dangle": 0, "no-shadow":1, "no-spaced-func":0, "func-call-spacing":0, "no-plusplus":0, "quote-props":0, "function-paren-newline":0, "no-inner-declarations":0, "camelcase":1, "func-names":0 } }

ESLint Ignore

touch .eslintignore

content

/build/** /coverage/** /docs/** /jsdoc/** /templates/** /tests/bench/** /tests/fixtures/** /tests/performance/** /tmp/** test.js !.eslintrc.js

Created on 1/17/2018