eslint-config-airbnb-extended 2.0.0-beta-2 → 2.0.0-beta-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -0
- package/dist/@types/legacy.d.ts +1 -1
- package/dist/legacy/configs/react/typescript.js +24 -12
- package/dist/legacy/configs/typescript/config.js +2 -0
- package/dist/legacy/rules/imports.js +4 -26
- package/dist/legacy/rules/react/react.js +1 -1
- package/dist/legacy/rules/typescript/typescript.js +6 -28
- package/dist/legacy/rules/typescript/typescriptSettings.js +27 -0
- package/dist/rules/node/nodeBase.js +3 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ To learn more about the configuration options available for `create-airbnb-x-con
|
|
|
20
20
|
|
|
21
21
|
### Steps
|
|
22
22
|
|
|
23
|
+
First, you need to decide whether you want to use the `legacy` config or the `extended` config. If you're not sure about the difference between the two, you can refer to the [Extended vs Legacy Config](https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/eslint-config-airbnb-extended#difference-between-extended-vs-legacy-config) for a brief explanation. For more information specifically about the Legacy config, check out the [Legacy Config](https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/eslint-config-airbnb-extended#legacy-config). If you decide to use the Extended config, you can proceed with the steps below. Otherwise, feel free to switch to the Legacy config if that better fits your requirements.
|
|
24
|
+
|
|
23
25
|
You can choose whether to **install** or **not install** based on your needs.
|
|
24
26
|
|
|
25
27
|
- If you choose **installation**, the package will automatically detect your project's package manager and install all the required dependencies.
|
|
@@ -33,6 +35,67 @@ While **manual installation** is possible, we strongly recommend using `create-a
|
|
|
33
35
|
|
|
34
36
|
The configuration may change over time, and `create-airbnb-x-config` will always stay up-to-date with the latest versions. If you're confident in handling manual installations, refer to the [Packages Used](https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/eslint-config-airbnb-extended#packages-used) section for more information on the individual packages.
|
|
35
37
|
|
|
38
|
+
## Legacy Config
|
|
39
|
+
|
|
40
|
+
Many people are currently using Airbnb's ESLint configs, like `eslint-config-airbnb`, and they want a way to switch or upgrade without making any changes to their existing config setup.
|
|
41
|
+
|
|
42
|
+
Right now, the new process for setting up configs is more complex, and not everyone wants to go through it. What developers really need is a simple and direct replacement for the existing Airbnb configs, a solution that keeps everything working the same way as before, with no rule or behavior changes. It should also make sure all packages used are updated to the latest versions.
|
|
43
|
+
|
|
44
|
+
In short, the goal is:
|
|
45
|
+
|
|
46
|
+
- No need to learn or adopt new config styles
|
|
47
|
+
- No changes in rule behavior or structure
|
|
48
|
+
- Easy to migrate by just changing the import path
|
|
49
|
+
- All packages should be latest
|
|
50
|
+
|
|
51
|
+
Here’s the way to use the **Airbnb legacy configurations** with the flat config format under `eslint-config-airbnb-extended/legacy`.
|
|
52
|
+
|
|
53
|
+
#### For `eslint-config-airbnb-base`
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { configs } from 'eslint-config-airbnb-extended/legacy';
|
|
57
|
+
|
|
58
|
+
// Equivalent to airbnb-base/legacy
|
|
59
|
+
export default [...configs.base.legacy];
|
|
60
|
+
|
|
61
|
+
// Equivalent to airbnb-base
|
|
62
|
+
export default [...configs.base.recommended];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
#### For `eslint-config-airbnb`
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { configs } from 'eslint-config-airbnb-extended/legacy';
|
|
71
|
+
|
|
72
|
+
// Equivalent to airbnb/legacy
|
|
73
|
+
export default [...configs.react.legacy];
|
|
74
|
+
|
|
75
|
+
// Equivalent to airbnb/base
|
|
76
|
+
export default [...configs.react.base];
|
|
77
|
+
|
|
78
|
+
// Equivalent to airbnb
|
|
79
|
+
export default [...configs.react.recommended];
|
|
80
|
+
|
|
81
|
+
// Equivalent to airbnb/hooks
|
|
82
|
+
export default [...configs.react.hooks];
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
#### For `eslint-config-airbnb-typescript`
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { configs } from 'eslint-config-airbnb-extended/legacy';
|
|
91
|
+
|
|
92
|
+
// Equivalent to airbnb-typescript/base
|
|
93
|
+
export default [...configs.base.typescript];
|
|
94
|
+
|
|
95
|
+
// Equivalent to airbnb-typescript
|
|
96
|
+
export default [...configs.react.typescript];
|
|
97
|
+
```
|
|
98
|
+
|
|
36
99
|
## Packages Used
|
|
37
100
|
|
|
38
101
|
This configuration relies on the following essential packages:
|
|
@@ -92,6 +155,12 @@ export default [
|
|
|
92
155
|
|
|
93
156
|
## FAQs
|
|
94
157
|
|
|
158
|
+
### Difference between Extended vs Legacy Config
|
|
159
|
+
|
|
160
|
+
**Legacy Config** – Designed to be a one-to-one replacement of the original Airbnb ESLint configurations using the new flat config format. Its main purpose is to maintain backward compatibility by continuing to use the same packages as the original setup. For more details, see the [Legacy Config](https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/eslint-config-airbnb-extended#legacy-config).
|
|
161
|
+
|
|
162
|
+
**Extended Config** – A modern ESLint configuration based on `eslint-config-airbnb`, built from scratch with updated rules, replacement of deprecated ones using community recommended alternatives, and the adoption of the latest best-practice packages. For more details on the packages used, refer to the [Packages Used](https://github.com/NishargShah/eslint-config-airbnb-extended/tree/master/packages/eslint-config-airbnb-extended#packages-used) section.
|
|
163
|
+
|
|
95
164
|
### How to Configure for a Monorepo?
|
|
96
165
|
|
|
97
166
|
If you're working in a monorepo setup, it's recommended to run the installation command in the specific sub-folder where you want the configuration. Alternatively, you can choose to skip the package installation, and we'll provide a customized set of commands based on your selection, allowing you to install it according to your preferred method.
|
package/dist/@types/legacy.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export declare const rules: {
|
|
5
5
|
readonly base: Record<"strict" | "imports" | "variables" | "bestPractices" | "errors" | "es6" | "style" | "node", import("eslint").Linter.Config>;
|
|
6
6
|
readonly react: Record<"base" | "jsxA11y" | "hooks", import("eslint").Linter.Config>;
|
|
7
|
-
readonly typescript: Record<"overrides" | "base", import("eslint").Linter.Config>;
|
|
7
|
+
readonly typescript: Record<"overrides" | "base" | "settings", import("eslint").Linter.Config>;
|
|
8
8
|
};
|
|
9
9
|
export declare const configs: {
|
|
10
10
|
readonly base: Record<"recommended" | "typescript" | "legacy", import("eslint").Linter.Config[]>;
|
|
@@ -3,23 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
6
|
+
const typescript_1 = __importDefault(require("../../../legacy/configs/base/typescript"));
|
|
7
7
|
const utils_1 = require("../../../utils");
|
|
8
8
|
const legacyReactTypescriptConfig = [
|
|
9
|
-
...
|
|
9
|
+
...typescript_1.default,
|
|
10
10
|
{
|
|
11
11
|
name: 'airbnb/config/react-configurations/typescript/legacy',
|
|
12
12
|
files: utils_1.tsFiles,
|
|
13
|
-
settings: {
|
|
14
|
-
// Append 'ts' extensions to Airbnb 'import/resolver' setting
|
|
15
|
-
// Prepend 'mjs' to match shared config
|
|
16
|
-
// Original: ['.js', '.jsx', '.json']
|
|
17
|
-
'import/resolver': {
|
|
18
|
-
node: {
|
|
19
|
-
extensions: ['.mjs', '.js', '.jsx', '.json', '.ts', '.tsx', '.d.ts'],
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
13
|
rules: {
|
|
24
14
|
// Append 'tsx' to Airbnb 'react/jsx-filename-extension' rule
|
|
25
15
|
// Original: ['.jsx']
|
|
@@ -31,5 +21,27 @@ const legacyReactTypescriptConfig = [
|
|
|
31
21
|
],
|
|
32
22
|
},
|
|
33
23
|
},
|
|
24
|
+
{
|
|
25
|
+
name: 'airbnb/config/react-configurations/typescript-settings/legacy',
|
|
26
|
+
files: utils_1.allFiles,
|
|
27
|
+
settings: {
|
|
28
|
+
// Apply special parsing for TypeScript files
|
|
29
|
+
'import/parsers': {
|
|
30
|
+
'@typescript-eslint/parser': utils_1.tsExtensionsWithReactDTS,
|
|
31
|
+
},
|
|
32
|
+
// Append 'ts' extensions to Airbnb 'import/resolver' setting
|
|
33
|
+
// Prepend 'mjs' to match shared config
|
|
34
|
+
// Original: ['.js', '.jsx', '.json']
|
|
35
|
+
'import/resolver': {
|
|
36
|
+
node: {
|
|
37
|
+
extensions: [...utils_1.tsExtensionsWithReactDTS, '.json'],
|
|
38
|
+
},
|
|
39
|
+
typescript: true,
|
|
40
|
+
},
|
|
41
|
+
// Append 'ts' extensions to Airbnb 'import/extensions' setting
|
|
42
|
+
// Original: ['.js', '.mjs', '.jsx']
|
|
43
|
+
'import/extensions': utils_1.tsExtensionsWithReactDTS,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
34
46
|
];
|
|
35
47
|
exports.default = legacyReactTypescriptConfig;
|
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const typescript_1 = __importDefault(require("../../../legacy/rules/typescript/typescript"));
|
|
7
7
|
const typescriptOverrides_1 = __importDefault(require("../../../legacy/rules/typescript/typescriptOverrides"));
|
|
8
|
+
const typescriptSettings_1 = __importDefault(require("../../../legacy/rules/typescript/typescriptSettings"));
|
|
8
9
|
const legacyTypescriptConfig = {
|
|
9
10
|
base: typescript_1.default,
|
|
10
11
|
overrides: typescriptOverrides_1.default,
|
|
12
|
+
settings: typescriptSettings_1.default,
|
|
11
13
|
};
|
|
12
14
|
exports.default = legacyTypescriptConfig;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const globals_1 = __importDefault(require("globals"));
|
|
7
|
+
const getDevDepsList_1 = __importDefault(require("../../helpers/getDevDepsList"));
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module
|
|
9
10
|
const plugin = require('eslint-plugin-import');
|
|
@@ -23,10 +24,10 @@ const legacyImportsRules = {
|
|
|
23
24
|
settings: {
|
|
24
25
|
'import/resolver': {
|
|
25
26
|
node: {
|
|
26
|
-
extensions: [
|
|
27
|
+
extensions: [...utils_1.jsExtensions, '.json'],
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
|
-
'import/extensions':
|
|
30
|
+
'import/extensions': utils_1.jsExtensionsWithReact,
|
|
30
31
|
'import/core-modules': [],
|
|
31
32
|
'import/ignore': ['node_modules', String.raw `\.(coffee|scss|css|less|hbs|svg|json)$`],
|
|
32
33
|
},
|
|
@@ -68,30 +69,7 @@ const legacyImportsRules = {
|
|
|
68
69
|
'import/no-extraneous-dependencies': [
|
|
69
70
|
'error',
|
|
70
71
|
{
|
|
71
|
-
devDependencies:
|
|
72
|
-
'test/**', // tape, common npm pattern
|
|
73
|
-
'tests/**', // also common npm pattern
|
|
74
|
-
'spec/**', // mocha, rspec-like pattern
|
|
75
|
-
'**/__tests__/**', // jest pattern
|
|
76
|
-
'**/__mocks__/**', // jest pattern
|
|
77
|
-
'test.{js,jsx}', // repos with a single test file
|
|
78
|
-
'test-*.{js,jsx}', // repos with multiple top-level test files
|
|
79
|
-
'**/*{.,_}{test,spec}.{js,jsx}', // tests where the extension or filename suffix denotes that it is a test
|
|
80
|
-
'**/jest.config.js', // jest config
|
|
81
|
-
'**/jest.setup.js', // jest setup
|
|
82
|
-
'**/vue.config.js', // vue-cli config
|
|
83
|
-
'**/webpack.config.js', // webpack config
|
|
84
|
-
'**/webpack.config.*.js', // webpack config
|
|
85
|
-
'**/rollup.config.js', // rollup config
|
|
86
|
-
'**/rollup.config.*.js', // rollup config
|
|
87
|
-
'**/gulpfile.js', // gulp config
|
|
88
|
-
'**/gulpfile.*.js', // gulp config
|
|
89
|
-
'**/Gruntfile{,.js}', // grunt config
|
|
90
|
-
'**/protractor.conf.js', // protractor config
|
|
91
|
-
'**/protractor.conf.*.js', // protractor config
|
|
92
|
-
'**/karma.conf.js', // karma config
|
|
93
|
-
'**/.eslintrc.js', // eslint config
|
|
94
|
-
],
|
|
72
|
+
devDependencies: (0, getDevDepsList_1.default)(utils_1.jsExtensions.map((ext) => ext.slice(1)).join(',')),
|
|
95
73
|
optionalDependencies: false,
|
|
96
74
|
},
|
|
97
75
|
],
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const typescript_eslint_1 = require("typescript-eslint");
|
|
7
|
+
const getDevDepsList_1 = __importDefault(require("../../../helpers/getDevDepsList"));
|
|
7
8
|
const best_practices_1 = __importDefault(require("../../../legacy/rules/best-practices"));
|
|
8
9
|
const errors_1 = __importDefault(require("../../../legacy/rules/errors"));
|
|
9
10
|
const es6_1 = __importDefault(require("../../../legacy/rules/es6"));
|
|
@@ -29,25 +30,6 @@ const legacyTypescriptBaseRules = {
|
|
|
29
30
|
projectService: true,
|
|
30
31
|
},
|
|
31
32
|
},
|
|
32
|
-
settings: {
|
|
33
|
-
// Apply special parsing for TypeScript files
|
|
34
|
-
'import/parsers': {
|
|
35
|
-
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts'],
|
|
36
|
-
},
|
|
37
|
-
// Append 'ts' extensions to Airbnb 'import/resolver' setting
|
|
38
|
-
// Original: ['.mjs', '.js', '.json']
|
|
39
|
-
'import/resolver': {
|
|
40
|
-
node: {
|
|
41
|
-
extensions: ['.mjs', '.js', '.json', '.ts', '.d.ts'],
|
|
42
|
-
},
|
|
43
|
-
typescript: true,
|
|
44
|
-
},
|
|
45
|
-
// Append 'ts' extensions to Airbnb 'import/extensions' setting
|
|
46
|
-
// Original: ['.js', '.mjs', '.jsx']
|
|
47
|
-
'import/extensions': ['.js', '.mjs', '.jsx', '.ts', '.tsx', '.d.ts'],
|
|
48
|
-
// Resolve type definition packages
|
|
49
|
-
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
|
|
50
|
-
},
|
|
51
33
|
rules: {
|
|
52
34
|
// Replace Airbnb 'brace-style' rule with '@typescript-eslint' version
|
|
53
35
|
// https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/brace-style.md
|
|
@@ -238,15 +220,11 @@ const legacyTypescriptBaseRules = {
|
|
|
238
220
|
// Append 'ts' and 'tsx' extensions to Airbnb 'import/no-extraneous-dependencies' rule
|
|
239
221
|
// https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-extraneous-dependencies.md
|
|
240
222
|
'import/no-extraneous-dependencies': [
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
toAppend.push(devDepWithTs);
|
|
247
|
-
}
|
|
248
|
-
return [...result, ...toAppend];
|
|
249
|
-
}, []) }),
|
|
223
|
+
'error',
|
|
224
|
+
{
|
|
225
|
+
devDependencies: (0, getDevDepsList_1.default)([...utils_1.jsExtensions, ...utils_1.tsExtensions].map((ext) => ext.slice(1)).join(',')),
|
|
226
|
+
optionalDependencies: false,
|
|
227
|
+
},
|
|
250
228
|
],
|
|
251
229
|
},
|
|
252
230
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../utils");
|
|
4
|
+
const legacyTypescriptSettingsRules = {
|
|
5
|
+
name: 'airbnb/config/typescript/settings/legacy',
|
|
6
|
+
files: utils_1.allFiles,
|
|
7
|
+
settings: {
|
|
8
|
+
// Apply special parsing for TypeScript files
|
|
9
|
+
'import/parsers': {
|
|
10
|
+
'@typescript-eslint/parser': utils_1.tsExtensionsResolver,
|
|
11
|
+
},
|
|
12
|
+
// Append 'ts' extensions to Airbnb 'import/resolver' setting
|
|
13
|
+
// Original: ['.mjs', '.js', '.json']
|
|
14
|
+
'import/resolver': {
|
|
15
|
+
node: {
|
|
16
|
+
extensions: [...utils_1.tsExtensionsResolver, '.json'],
|
|
17
|
+
},
|
|
18
|
+
typescript: true,
|
|
19
|
+
},
|
|
20
|
+
// Append 'ts' extensions to Airbnb 'import/extensions' setting
|
|
21
|
+
// Original: ['.js', '.mjs', '.jsx']
|
|
22
|
+
'import/extensions': utils_1.tsExtensionsResolver,
|
|
23
|
+
// Resolve type definition packages
|
|
24
|
+
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
exports.default = legacyTypescriptSettingsRules;
|
|
@@ -88,6 +88,9 @@ const nodeBaseRules = {
|
|
|
88
88
|
ignores: [],
|
|
89
89
|
},
|
|
90
90
|
],
|
|
91
|
+
// Disallow top-level await in published modules
|
|
92
|
+
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-top-level-await.md
|
|
93
|
+
'n/no-top-level-await': 'off',
|
|
91
94
|
// Disallow bin files that npm ignores
|
|
92
95
|
// https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-unpublished-bin.md
|
|
93
96
|
'n/no-unpublished-bin': 'error',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-airbnb-extended",
|
|
3
|
-
"version": "2.0.0-beta-
|
|
3
|
+
"version": "2.0.0-beta-4",
|
|
4
4
|
"description": "Eslint Airbnb Config Extended",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@stylistic/eslint-plugin": "^3.1.0",
|
|
47
47
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
48
|
-
"@types/node": "^
|
|
48
|
+
"@types/node": "^24.0.1",
|
|
49
49
|
"rimraf": "^6.0.1",
|
|
50
50
|
"tsc-alias": "^1.8.16",
|
|
51
|
-
"tsx": "^4.
|
|
51
|
+
"tsx": "^4.20.3",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
|
-
"typescript-eslint": "^8.
|
|
53
|
+
"typescript-eslint": "^8.34.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@next/eslint-plugin-next": "15.x",
|