Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eslint config] [base] [breaking] support eslint 8 #2495

Merged
merged 6 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
with:
versionsAsRoot: true
type: 'majors'
preset: '^10 || ^12 || ^14 || ^16 || >= 17'
preset: '^12 || ^14 || ^16 || >= 17'

base:
needs: [matrix]
Expand All @@ -25,11 +25,14 @@ jobs:
matrix:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 8
- 7
- 6
- 5
package:
- eslint-config-airbnb-base
exclude:
- node-version: 10
eslint: 8
package: eslint-config-airbnb-base

defaults:
run:
Expand Down Expand Up @@ -60,15 +63,15 @@ jobs:
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 7
- 6
- 5
# - 6
# - 5
package:
- eslint-config-airbnb
react-hooks:
- ''
- 3
- 2.3
- 1.7
# - 3 # TODO: re-enable these once the react config uses eslint 8
# - 2.3
# - 1.7

defaults:
run:
Expand Down Expand Up @@ -97,9 +100,8 @@ jobs:
fail-fast: false
matrix:
eslint:
- 8
- 7
- 6
- 5
package:
- eslint-config-airbnb-base

Expand All @@ -119,7 +121,7 @@ jobs:
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm run pretravis
- run: npm run prepublish
- run: npm run prepublishOnly
- run: npm run posttravis

prepublish-react:
Expand All @@ -130,15 +132,15 @@ jobs:
matrix:
eslint:
- 7
- 6
- 5
# - 6
# - 5
package:
- eslint-config-airbnb
react-hooks:
- ''
- 3
- 2.3
- 1.7
# - 3 # TODO: re-enable these once the react config uses eslint 8
# - 2.3
# - 1.7

defaults:
run:
Expand All @@ -158,7 +160,7 @@ jobs:
- run: node -pe "require('eslint/package.json').version"
name: 'eslint version'
- run: npm run pretravis
- run: npm run prepublish
- run: npm run prepublishOnly
- run: npm run posttravis

node:
Expand Down
19 changes: 19 additions & 0 deletions packages/eslint-config-airbnb-base/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
15.0.0 / 2021-11-08
==================
- [breaking] drop eslint < 7, add eslint 8 (#2495)
- [breaking] add `exports`
- [patch] Improve `function-paren-newline` with `multiline-arguments` option (#2471)
- [patch] update default value for complexity (#2420)
- [patch] add disabled `no-unsafe-optional-chaining` rule
- [patch] arthmetic -> arithmetic (#2341)
- [patch] fix spelling of "than" (#2333)
- [patch] add `no-nonoctal-decimal-escape` rule
- [patch] `import/no-extraneous-dependencies`: Add .eslintrc.js to devDeps (#2329)
- [guide] Spread operator => Spread syntax (#2423)
- [guide] add references for eslint rules (#2419)
- [Docs] HTTP => HTTPS (#2489)
- [readme] some updates
- [meta] use `prepublishOnly` script for npm 7+
- [deps] update `eslint-plugin-import`, `eslint-plugin-react`, `object.entries`
- [dev deps] update `@babel/runtime`, ``tape`

14.2.1 / 2020-11-06
==================
- [base] `no-restricted-globals`: add better messages (#2320)
Expand Down
19 changes: 16 additions & 3 deletions packages/eslint-config-airbnb-base/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# eslint-config-airbnb-base
# eslint-config-airbnb-base <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)](https://badge.fury.io/js/eslint-config-airbnb-base)
[![npm version](https://badge.fury.io/js/eslint-config-airbnb-base.svg)][package-url]

[![github actions][actions-image]][actions-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

This package provides Airbnb's base JS .eslintrc (without React plugins) as an extensible shared config.

Expand Down Expand Up @@ -79,7 +83,7 @@ Lints ES5 and below. Requires `eslint` and `eslint-plugin-import`.
Which produces and runs a command like:

```sh
npm install --save-dev eslint-config-airbnb-base eslint@^3.0.1 eslint-plugin-import@^1.10.3
npm install --save-dev eslint-config-airbnb-base eslint@^#.#.# eslint-plugin-import@^#.#.#
```

2. Add `"extends": "airbnb-base/legacy"` to your .eslintrc
Expand All @@ -97,3 +101,12 @@ Consider adding test cases if you're making complicated rules changes, like anyt
You can run tests with `npm test`.

You can make sure this module lints with itself using `npm run lint`.

[package-url]: https://npmjs.org/package/eslint-config-airbnb-base
[npm-version-svg]: https://versionbadg.es/airbnb/javascript.svg
[license-image]: https://img.shields.io/npm/l/eslint-config-airbnb-base.svg
[license-url]: LICENSE.md
[downloads-image]: https://img.shields.io/npm/dm/eslint-config-airbnb-base.svg
[downloads-url]: https://npm-stat.com/charts.html?package=eslint-config-airbnb-base
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/airbnb/javascript
[actions-url]: https://github.com/airbnb/javascript/actions
26 changes: 20 additions & 6 deletions packages/eslint-config-airbnb-base/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
{
"name": "eslint-config-airbnb-base",
"version": "14.2.1",
"version": "15.0.0",
"description": "Airbnb's base JS ESLint config, following our styleguide",
"main": "index.js",
"exports": {
".": "./index.js",
"./legacy": "./legacy.js",
"./whitespace": "./whitespace.js",
"./rules/best-practices": "./rules/best-practices.js",
"./rules/es6": "./rules/es6.js",
"./rules/node": "./rules/node.js",
"./rules/style": "./rules/style.js",
"./rules/errors": "./rules/errors.js",
"./rules/imports": "./rules/imports.js",
"./rules/strict": "./rules/strict.js",
"./rules/variables": "./rules/variables.js",
"./package.json": "./package.json"
},
"scripts": {
"prelint": "eclint check * rules/* test/*",
"lint": "eslint --report-unused-disable-directives .",
Expand Down Expand Up @@ -58,19 +72,19 @@
"babel-preset-airbnb": "^4.5.0",
"babel-tape-runner": "^3.0.0",
"eclint": "^2.8.1",
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-find-rules": "^3.6.1",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-find-rules": "^4.0.0",
"eslint-plugin-import": "^2.25.2",
"in-publish": "^2.0.1",
"safe-publish-latest": "^1.1.4",
"safe-publish-latest": "^2.0.0",
"tape": "^5.3.1"
},
"peerDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint": "^7.32.0 || ^8.2.0",
"eslint-plugin-import": "^2.25.2"
},
"engines": {
"node": ">= 6"
"node": "^10.12.0 || >=12.0.0"
},
"dependencies": {
"confusing-browser-globals": "^1.0.10",
Expand Down
20 changes: 8 additions & 12 deletions packages/eslint-config-airbnb-base/rules/best-practices.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@ module.exports = {

// Enforce default clauses in switch statements to be last
// https://eslint.org/docs/rules/default-case-last
// TODO: enable, semver-minor, when eslint v7 is required (which is a major)
'default-case-last': 'off',
'default-case-last': 'error',

// https://eslint.org/docs/rules/default-param-last
// TODO: enable, semver-minor, when eslint v6.4 is required (which is a major)
'default-param-last': 'off',
'default-param-last': 'error',

// encourages use of dot notation whenever possible
// https://eslint.org/docs/rules/dot-notation
Expand All @@ -57,8 +55,7 @@ module.exports = {

// Require grouped accessor pairs in object literals and classes
// https://eslint.org/docs/rules/grouped-accessor-pairs
// TODO: enable in next major, altho the guide forbids getters/setters anyways
'grouped-accessor-pairs': 'off',
'grouped-accessor-pairs': 'error',

// make sure for-in loops have an if statement
// https://eslint.org/docs/rules/guard-for-in
Expand All @@ -82,8 +79,7 @@ module.exports = {

// Disallow returning value in constructor
// https://eslint.org/docs/rules/no-constructor-return
// TODO: enable, semver-major
'no-constructor-return': 'off',
'no-constructor-return': 'error',

// disallow division operators explicitly at beginning of regular expression
// https://eslint.org/docs/rules/no-div-regex
Expand Down Expand Up @@ -213,8 +209,7 @@ module.exports = {

// Disallow \8 and \9 escape sequences in string literals
// https://eslint.org/docs/rules/no-nonoctal-decimal-escape
// todo: semver-major: enable when v7.14 is required
'no-nonoctal-decimal-escape': 'off',
'no-nonoctal-decimal-escape': 'error',

// disallow use of (old style) octal literals
// https://eslint.org/docs/rules/no-octal
Expand Down Expand Up @@ -382,8 +377,9 @@ module.exports = {
'prefer-named-capture-group': 'off',

// https://eslint.org/docs/rules/prefer-regex-literals
// TODO; enable, semver-minor, once eslint v6.4 is required (which is a major)
'prefer-regex-literals': 'off',
'prefer-regex-literals': ['error', {
disallowRedundantWrapping: true,
}],

// require use of the second argument for parseInt()
// https://eslint.org/docs/rules/radix
Expand Down
29 changes: 13 additions & 16 deletions packages/eslint-config-airbnb-base/rules/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ module.exports = {

// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/rules/no-dupe-else-if
// TODO: enable, semver-major
'no-dupe-else-if': 'off',
'no-dupe-else-if': 'error',

// disallow duplicate keys when creating object literals
'no-dupe-keys': 'error',
Expand Down Expand Up @@ -79,8 +78,7 @@ module.exports = {
'no-func-assign': 'error',

// https://eslint.org/docs/rules/no-import-assign
// TODO: enable, semver-minor, once eslint v6.4 is required (which is a major)
'no-import-assign': 'off',
'no-import-assign': 'error',

// disallow function or variable declarations in nested blocks
'no-inner-declarations': 'error',
Expand All @@ -93,8 +91,7 @@ module.exports = {

// Disallow Number Literals That Lose Precision
// https://eslint.org/docs/rules/no-loss-of-precision
// TODO: enable, semver-minor, once eslint v7.1 is required (which is major)
'no-loss-of-precision': 'off',
'no-loss-of-precision': 'error',

// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/rules/no-misleading-character-class
Expand All @@ -105,8 +102,7 @@ module.exports = {

// Disallow returning values from Promise executor functions
// https://eslint.org/docs/rules/no-promise-executor-return
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-promise-executor-return': 'off',
'no-promise-executor-return': 'error',

// disallow use of Object.prototypes builtins directly
// https://eslint.org/docs/rules/no-prototype-builtins
Expand All @@ -117,8 +113,7 @@ module.exports = {

// Disallow returning values from setters
// https://eslint.org/docs/rules/no-setter-return
// TODO: enable, semver-major (altho the guide forbids getters/setters already)
'no-setter-return': 'off',
'no-setter-return': 'error',

// disallow sparse arrays
'no-sparse-arrays': 'error',
Expand All @@ -136,8 +131,7 @@ module.exports = {

// Disallow loops with a body that allows only one iteration
// https://eslint.org/docs/rules/no-unreachable-loop
// TODO: enable, semver-minor, once eslint v7.3 is required (which is major)
'no-unreachable-loop': ['off', {
'no-unreachable-loop': ['error', {
ignore: [], // WhileStatement, DoWhileStatement, ForStatement, ForInStatement, ForOfStatement
}],

Expand All @@ -151,13 +145,16 @@ module.exports = {

// disallow use of optional chaining in contexts where the undefined value is not allowed
// https://eslint.org/docs/rules/no-unsafe-optional-chaining
// TODO: enable, semver-minor, once eslint v7.15 is required (which is major)
'no-unsafe-optional-chaining': ['off', { disallowArithmeticOperators: true }],
'no-unsafe-optional-chaining': ['error', { disallowArithmeticOperators: true }],

// Disallow Unused Private Class Members
// https://eslint.org/docs/rules/no-unused-private-class-members
// TODO: enable once eslint 7 is dropped (which is semver-major)
'no-unused-private-class-members': 'off',

// Disallow useless backreferences in regular expressions
// https://eslint.org/docs/rules/no-useless-backreference
// TODO: enable, semver-minor, once eslint v7 is required (which is major)
'no-useless-backreference': 'off',
'no-useless-backreference': 'error',

// disallow negation of the left operand of an in expression
// deprecated in favor of no-unsafe-negation
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-config-airbnb-base/rules/es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ module.exports = {

// Disallow specified names in exports
// https://eslint.org/docs/rules/no-restricted-exports
// TODO enable, semver-minor, once eslint v7 is required (which is major)
'no-restricted-exports': ['off', {
'no-restricted-exports': ['error', {
restrictedNamedExports: [
'default', // use `export default` to provide a default export
'then', // this will cause tons of confusion when your module is dynamically `import()`ed
'then', // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
],
}],

Expand Down
8 changes: 3 additions & 5 deletions packages/eslint-config-airbnb-base/rules/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module.exports = {

// Reports modules without any exports, or with unused exports
// https://github.com/benmosher/eslint-plugin-import/blob/f63dd261809de6883b13b6b5b960e6d7f42a7813/docs/rules/no-unused-modules.md
// TODO: enable, semver-major
// TODO: enable once it supports CJS
'import/no-unused-modules': ['off', {
ignoreExports: [],
missingExports: true,
Expand All @@ -262,14 +262,12 @@ module.exports = {

// Reports the use of import declarations with CommonJS exports in any module except for the main module.
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-import-module-exports.md
// TODO: enable, semver-major
'import/no-import-module-exports': ['off', {
'import/no-import-module-exports': ['error', {
exceptions: [],
}],

// Use this rule to prevent importing packages through relative paths.
// https://github.com/benmosher/eslint-plugin-import/blob/1012eb951767279ce3b540a4ec4f29236104bb5b/docs/rules/no-relative-packages.md
// TODO: enable, semver-major
'import/no-relative-packages': 'off',
'import/no-relative-packages': 'error',
},
};
Loading