パッケージの詳細

eslint-config-exp

BonnierNews276MIT非推奨0.8.3

This package has been superseded by @bonniernews/eslint-config, please upgrade.

ESLint config

eslint, eslintconfig, config, expressen

readme

eslint-config-exp

Test application

Basic ESLint rules used by Expressen. The configuration works both with CommonJS and ES6 modules, and the appropriate setup will be used by looking at the projects package.json type property.

For Node versions that support it (version 16 and above), the es2022 environment will also be activated. Otherwise es2021 will be used.

Usage

Install eslint and eslint-config-exp:

npm install --save-dev eslint eslint-config-exp

Base configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "exp" ]
}

React configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "exp/react" ]
}

This will enable the react plugin for *.jsx-files.

TypeScript configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "exp/typescript" ]
}

This will enable the typescript plugin for *.ts-files.

React with TypeScript configuration

To activate the config, you need to add the following to your .eslintrc.json-file:

{
  "root": true,
  "extends": [ "exp/typescript-react" ]
}

This will enable the typescript and react plugin for *.tsx-files.

Test configuration

You can also choose to use the test config, which is adapted to testing using mocha, mocha-cakes-2 and chai. To also enable this, either add a separate test configuration file extending from "exp/test", or use the "exp/all" in your root configuration to activate everything together:

{
  "root": true,
  "extends": [ "exp/all" ]
}

This will activate the test configuration for all files inside directories named test or tests.

Running eslint

Run with:

npx eslint .

Usage in an existing project

  • We advice to remove any husky hooks that uses libraries such as pretty-quick from your package.json
  • Subsequently remove any use of pretty-quick if possible.
  • Remove any previous use of sharable ESLint configs from package.json, i.e.:
    • eslint-config-airbnb
    • eslint-config-google
    • eslint-config-prettier
  • Remove eslint-plugin-prettier from package.json
  • If you get errors similar to the ones below, please update the eslint dependancy.
    • Definition for rule 'no-nonoctal-decimal-escape' was not found
    • Definition for rule 'no-unsafe-optional-chaining' was not found
  • If you still have issues; try updating npm (if you use nvm nvm install-latest-npm) & prettier as-well
  • Remove any 'eslint-disable-line no-unused-expressions' directives added because of chai assertions, they are not needed anymore (eslint-plugin-chai-friendly is used in test).
  • Remove any globals and special rules related to mocha-cakes-2 in your test configuration, they already exist in the eslint-config-exp/test and eslint-config-exp/all configs.

Once you complete the steps above run the following:

npx eslint . --fix

Usage with Prettier

If you want to use Prettier, run it before eslint. ESLint should be the final judge, i.e. run:

npx prettier --save .
npx eslint . --fix

This will format the entire code base according to the rules of Prettier and the config.

Enable format on save

Changelog

Can be found here.

License

Released under the MIT license.

更新履歴

Changelog

0.8.3

  • fixed typescript-react rules to actually check .ts files
  • disabled import/named for typescript

0.8.2

  • bump typescript deps

0.8.1

  • fixed broken release

0.8.0

  • tsx support by using exp/typescript-react
  • removed warning for explicit anys

0.7.0

  • TypeScript rules.
  • Bumped major version of eslint-plugin-n to 16.
  • Bumped major version of eslint-plugin-no-only-tests to 3.
  • Bumped required node version to 16.
  • Added TypeScript as an optional peer dependency.

0.6.2

0.6.1

  • Added "react/jsx-indent-props": [2, 2] as a rule for react to make indenting jsx props look nice.

0.6.0

  • Added support for react using exp/react.

0.5.0

Add deprecated rules for node.

0.4.0

  • Replace eslint-plugin-node with eslint-plugin-n as the former is no longer maintained.

0.3.0

Added missing afterEachFeature & beforeEachFeature globals for mocha-cakes-2.

0.2.0

  • Added support for ES6 module linting, which is activated if "type": "module" in your package.json
  • For Node versions 16 and above, the ES2022 environment will be activated
  • A new configuration exp/all has been added, which adds the test configuration directly in the main .eslintrc.json

0.1.1

Consistent spacing for functions and code blocks.

0.1.0

New rules to format objects: either all properties on the same line OR use multiline.

0.0.9

Updated eslint peer dependency to v8.

0.0.8

eslint-plugin-node is now included in the package and has migrated the following rules:

  • node/handle-callback-err
  • node/no-path-concat
  • node/no-process-exit

Behavior remains unchanged.

0.0.7

function is now exempt from the comma-dangle rule.

0.0.6

Add the comma-dangle rule with always-multiline.

0.0.5

Add the switch-colon-spacing rule.

0.0.4

Remove some ignorePatterns that shouldn't be ignored.

0.0.3

No changes. Fixes bad publish.

0.0.2

Use new-cap in standard configuration.

0.0.1

Initial working version.