Shareable ESLint config, based on airbnb/javascript, bundled as a plugin
MIT License
Shareable ESLint config, based on airbnb/javascript, bundled as a plugin.
We want shareable configs to have as low of an overhead as possible. Users shouldn't have to know exactly what plugins are required by the config, install them and manage their versions manually. This plugin contains a shareable config, with plugin dependencies automatically installed.
See https://github.com/eslint/eslint/issues/3458 for further discussion on this topic.
Install ESLint and the config:
npm install --save-dev eslint @thibaudcolas/eslint-plugin-cookbook
Then configure ESLint to use this config. As a .eslintrc.js
in the root of your project:
module.exports = {
// https://github.com/thibaudcolas/eslint-plugin-cookbook
extends: "plugin:@thibaudcolas/cookbook/recommended",
};
This recommended config is Prettier-compatible. First, install Prettier:
npm install --save-dev prettier
Then, to configure Prettier itself, create a prettier.config.js
file in the root of your project. You can use the following to get started:
// https://github.com/thibaudcolas/eslint-plugin-cookbook
module.exports = require("@thibaudcolas/eslint-plugin-cookbook/prettier.config");
Read on: Upgrading to a stricter ESLint config.
Should further customisation be required, rules coming from external plugins require the @thibaudcolas/cookbook
prefix:
module.exports = {
// https://github.com/thibaudcolas/eslint-plugin-cookbook
extends: "plugin:@thibaudcolas/cookbook/recommended",
rules: {
- "react/react-in-jsx-scope": ["warn"],
+ "@thibaudcolas/cookbook/react/react-in-jsx-scope": ["warn"],
- "import/prefer-default-export": ["warn"],
+ "@thibaudcolas/cookbook/import/prefer-default-export": ["warn"],
},
};
--report-unused-disable-directives
flag to ensure you do not use more eslint-disable
comments than needed.To get the most out of this config, it is assumed that projects have the following tools set up:
1, terms: todo, fixme, xxx, location: start
2, devDependencies: test/**, tests/**, spec/**, **/__tests__…
2, extensions: .js
2, props: false
2, forbid: any
airbnb
error, components:
error, ignoreNonDom: false, ignoreNonDOM: false
error, elements: img, object, area, inputtype=\image\, img: …
error, labelComponents: , labelAttributes: , controlComponen…
error, labelAttributes: label, controlComponents: , ignoreEl…
error, components:
error, elements: marquee, blink
error, handlers: onClick, onMouseDown, onMouseUp, onKeyPress…
error, handlers: onClick, onMouseDown, onMouseUp, onKeyPress…
error, ignoreNonDOM: true
error, audio: , video: , track:
error, tr: none, presentation
error, ul: listbox, menu, menubar, radiogroup, tablist, tree…
error, tags: , roles: tabpanel
error, components: Link, specialLink: to, aspects: noHref, i…
error, allow: __REDUX_DEVTOOLS_EXTENSION_COMPOSE__, allowAft…
error, exceptMethods: render, getInitialState, getDefaultPro…
error, never, always:
error, ignoreCase: true
error, allowAllCaps: true, ignore:
warn
error, always
error, ignorePureComponents: true
error, ignore: , customValidators: , skipUndeclared: false
error, order: static-variables, static-methods, instance-var…
error, enforceDynamicLinks: always
error, customValidators: , skipShapeProps: true
error, forbidDefaultForRequired: true
warn, allowInPropTypes: true
error, allowRequiredDefaults: false
error, props: never, children: never
error, always
error, button: true, submit: true, reset: false
error, syntax
error, always
error, property assignment
error, html: enforce, custom: enforce, exceptions:
error, never
error, commonjs: true, caseSensitive: true
error, ignorePackages, js: never, mjs: never, jsx: never
error, groups: builtin, external, internal
error, commonjs: true
error, ignoreDestructuring: false, ignoreImport: false, igno…
error, always, ignoreConstructors: false, avoidQuotes: true
error, destructuring: any, ignoreReadBeforeAssign: true
error, VariableDeclarator: array: false, object: true, Assig…
error, isFinite, isNaN, addEventListener, blur, close, close…
error, vars: all, args: after-used, ignoreRestSiblings: true
error, functions: true, classes: true, variables: true
error, properties: never, ignoreDestructuring: false, ignore…
warn
error, always, exceptAfterSingleLine: false
error, before: always, after: always
error, newIsCap: true, newIsCapExceptions: , capIsNew: false…
error, selector: ForInStatement, message: for..in loops iter…
error, defaultAssignment: false
error, never
error, always
error, always, line: exceptions: -, +, markers: =, !, block:…
error, allowImplicit: true
error, always
warn
warn
error, requireStringLiterals: true
error, allowImplicit: true, checkForEach: false
error, commentPattern: ^no default$
error, allowKeywords: true, allowPattern:
error, always, null: ignore
error, 1
warn
error, allowElseIf: false
error, allow: arrowFunctions, functions, methods
error, exceptions:
error, allowLoop: false, allowSwitch: false
error, object: arguments, property: callee, message: argumen…
error, always
error, props: true
error, allowShortCircuit: false, allowTernary: false, allowT…
error, allowEmptyReject: true