Colorful Company's ESLint shareable config.
yarn add -D eslint https://github.com/colorfulcompany/eslint-config-colorfulcompany eslint-config-standard eslint-plugin-import eslint-plugin-jsdoc eslint-plugin-node eslint-plugin-promise
For Node.js environment.
For browser environment. But enable the Node.js environment in consideration of using the bundler.
Add this to your .eslintrc.js
file:
module.exports = {
extends: 'colorfulcompany/browser' // or 'colorfulcompany/node'
}
- Extends
standard
- Extends
plugin:jsdoc/recommended
- No console on production.
- No debugger on production.
- Require JSDoc for arrow function expression.
/**
*
* @param {string} hoge
*/
const hoge = (input) => {
console.log(input)
}
- Require JSDoc for class declaration.
/**
* This is a description.
*/
class Hoge {...}
- Require JSDoc for function declaration.
/**
* @param {string} input
*/
function hoge (input) {...}
- Require JSDoc for method definition.
class Hoge {
/**
* @param {string} input
*/
fuga (input) {...}
}
- JSDoc param description is optional.
- JSDoc returns description is optional.
- Don't use default export.
export default class Hoge {...} // ✗ avoid
export class Hoge {...} // ✓ ok
It is probably set to the latest version of ECMAScript by eslint-config-standard
, but for this project it is not specified.
As of October 2021, ES2018 is not yet supported by most browsers, so limit it to ES2017 for now.
The transpilers are not perfect. Some functions may be delivered to the user without being transpiled. Specifically, these are as follows.
- RegExp named capture groups (ES2018)
- RegExp Lookbehind Assertions (ES2018)
- Flat array methods (ES2019)
So we made a policy of restricting to ES2017, with or without a transpiler.
If with a namespace like @colorfulcompany/eslint-config
, when define multiple variants, way to extend is like this:
module.exports = {
extends: '@colorfulcompany/eslint-config/browser'
}
This way is a bit redundant.