cc-kawakami / eslint-config-colorfulcompany

Colorful Company's shareable ESLint config

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

English / 日本語

Colorful Company's ESLint config

Colorful Company's ESLint shareable config.

Install

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

Config variants

colorfulcompany/node

For Node.js environment.

colorfulcompany/browser

For browser environment. But enable the Node.js environment in consideration of using the bundler.

Usage

Add this to your .eslintrc.js file:

module.exports = {
  extends: 'colorfulcompany/browser' // or 'colorfulcompany/node'
}

Rules

/**
 *
 * @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

ECMAScript version

colorfulcompany/node: ECMAScript version is not specified.

It is probably set to the latest version of ECMAScript by eslint-config-standard, but for this project it is not specified.

colorfulcompany/browser: Env and parser is set to ES2017.

As of October 2021, ES2018 is not yet supported by most browsers, so limit it to ES2017 for now.

Is the ECMAScript version restriction not necessary when using a transpiler?

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.

Why not use namespaces @colorfulcompany ?

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.

Direct dependencies

References

About

Colorful Company's shareable ESLint config

License:MIT License


Languages

Language:JavaScript 94.5%Language:Shell 5.5%