eslint-config-lydell 
Kinda strict Prettier-friendly ESLint config.
- Only rules by default. No other config.
- Optional: A less confusing
browser env.
- No rules that that are unnecessary or might conflict with Prettier.
- Find errors.
- Avoid potential problems.
- Forbid confusing code.
- Prefer ES2015+ syntax.
- Avoid rules that require arbitrary configuration.
Installation
Install eslint-config-lydell:
$ npm install --save-dev eslint-config-lydell
Then, merge in the rules in your .eslintrc.js file. (You have to use .js
for your ESLint config; see below.)
const baseRules = require("eslint-config-lydell");
module.exports = {
rules: Object.assign({}, baseRules(), {
}),
globals: Object.assign({}, baseRules.browserEnv(), {
}),
};
A few ESLint plugins are supported as well:
Note that you need to install those plugins yourself. (They are not included in the config because of ESLint issue #3458.)
Enable rules for the plugins you use like so:
baseRules({ flow: true, import: true, jest: true, react: true });
The reason this config is require:d instead of using the extends field
(which is the standard), is to easily allow flow to opt out from some base and
react rules, for example.
The config also comes with a browser env (globals), that is exactly like the
standard browser env in ESLint but without all the weird stuff like name and
length. (Prefix uncommon globals with window. or add them to your config.)
Example configuration
This includes some extra recommended plugins, that don't need a ton of
configuration:
It also shows how to set up linting for config files, Storybook stories and
Jest tests.
const baseRules = require("eslint-config-lydell");
module.exports = {
root: true,
plugins: [
"import",
"jest",
"flowtype",
"react",
"react-hooks",
"prettier",
"simple-import-sort",
"css-modules",
"flowtype-errors",
],
parserOptions: {
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
env: {
es6: true,
},
globals: Object.assign({}, baseRules.browserEnv(), {
DEBUG: false,
}),
rules: Object.assign(
{},
baseRules({ flow: true, import: true, jest: true, react: true }),
{
"css-modules/no-undef-class": "error",
"flowtype-errors/show-errors": "error",
"prettier/prettier": "error",
"simple-import-sort/sort": "error",
}
),
overrides: [
{
files: [".*.js", "*.config.js", ".storybook/*.js"],
env: { node: true },
rules: {
"flowtype/require-valid-file-annotation": "off",
},
},
{
files: ["*.test.js"],
env: { jest: true },
rules: baseRules({ builtin: false, jest: true }),
},
{
files: ["stories.js"],
globals: {
module: false,
},
},
{
files: ["server/**/*.js"],
env: { node: true },
rules: {
"import/order": ["error", { "newlines-between": "always" }],
},
},
],
settings: {
react: {
version: "detect",
},
},
};
Recommended .eslintignore:
# Un-ignore config files.
!/*.js
!/.storybook/
!/**/.eslintrc.js
# You might want to ignore some directories:
# /build/
Recommended prettier.config.js:
module.exports = {
trailingComma: "es5",
};
License
MIT.
Version 14.0.0 (2019-02-26)
- Added: [jest/prefer-todo].
- Added: [eslint-plugin-react-hooks] rules. This plugin is now required to
install if you use
react: true.
- Removed: [react/self-closing-comp]. Itâs not needed when using Prettier.
- Removed: [camelcase]. APIâs often uses snake case in response objects, and
itâs annoying not being able to do
const { full_name } = apiResponse
without renaming.