eslint-stylistic-airbnb 3.0.0-rc.1 → 3.0.0-rc.2

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 CHANGED
@@ -61,13 +61,13 @@ Install the core packages:
61
61
 
62
62
  ```bash
63
63
  # npm
64
- npm install -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb
64
+ npm install -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb globals
65
65
 
66
66
  # pnpm
67
- pnpm add -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb
67
+ pnpm add -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb globals
68
68
 
69
69
  # yarn
70
- yarn add -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb
70
+ yarn add -D eslint @stylistic/eslint-plugin eslint-stylistic-airbnb globals
71
71
  ```
72
72
 
73
73
  ## Quickstart
@@ -84,9 +84,16 @@ You can either use flat `eslint.config.js` (recommended) or legacy `.eslintrc` (
84
84
  ```javascript
85
85
  // eslint.config.js
86
86
  import airbnb from 'eslint-stylistic-airbnb';
87
+ import globals from 'globals';
87
88
 
88
89
  export default [
89
90
  airbnb.configs['flat/recommended'],
91
+
92
+ {
93
+ languageOptions: {
94
+ globals: globals.browser,
95
+ },
96
+ },
90
97
  ];
91
98
  ```
92
99
 
@@ -95,10 +102,19 @@ export default [
95
102
  // eslint.config.js
96
103
  import airbnb from 'eslint-stylistic-airbnb';
97
104
  import tseslint from 'typescript-eslint';
105
+ import globals from 'globals';
98
106
 
99
107
  export default [
100
108
  ...tseslint.configs.recommended,
109
+
101
110
  airbnb.configs['flat/recommended'],
111
+ airbnb.configs['flat/addon-typescript'],
112
+
113
+ {
114
+ languageOptions: {
115
+ globals: globals.browser,
116
+ },
117
+ },
102
118
  ];
103
119
  ```
104
120
 
@@ -108,13 +124,21 @@ export default [
108
124
  import airbnb from 'eslint-stylistic-airbnb';
109
125
  import react from 'eslint-plugin-react';
110
126
  import reactHooks from 'eslint-plugin-react-hooks';
127
+ import globals from 'globals';
111
128
 
112
129
  export default [
113
- airbnb.configs['flat/recommended'],
114
130
  react.configs.flat.recommended,
115
131
  reactHooks.configs.recommended,
116
- airbnb.configs['flat/jsx'],
117
- airbnb.configs['flat/react'],
132
+
133
+ airbnb.configs['flat/recommended'],
134
+ airbnb.configs['flat/addon-jsx'],
135
+ airbnb.configs['flat/addon-react'],
136
+
137
+ {
138
+ languageOptions: {
139
+ globals: globals.browser,
140
+ },
141
+ },
118
142
  ];
119
143
  ```
120
144
 
@@ -125,14 +149,23 @@ import airbnb from 'eslint-stylistic-airbnb';
125
149
  import react from 'eslint-plugin-react';
126
150
  import reactHooks from 'eslint-plugin-react-hooks';
127
151
  import tseslint from 'typescript-eslint';
152
+ import globals from 'globals';
128
153
 
129
154
  export default [
130
155
  ...tseslint.configs.recommended,
131
- airbnb.configs['flat/recommended'],
132
156
  react.configs.flat.recommended,
133
157
  reactHooks.configs.recommended,
134
- airbnb.configs['flat/jsx'],
135
- airbnb.configs['flat/react'],
158
+
159
+ airbnb.configs['flat/recommended'],
160
+ airbnb.configs['flat/addon-typescript'],
161
+ airbnb.configs['flat/addon-jsx'],
162
+ airbnb.configs['flat/addon-react'],
163
+
164
+ {
165
+ languageOptions: {
166
+ globals: globals.browser,
167
+ },
168
+ },
136
169
  ];
137
170
  ```
138
171
 
@@ -141,11 +174,19 @@ export default [
141
174
  // eslint.config.js
142
175
  import airbnb from 'eslint-stylistic-airbnb';
143
176
  import pluginVue from 'eslint-plugin-vue';
177
+ import globals from 'globals';
144
178
 
145
179
  export default [
146
180
  ...pluginVue.configs['flat/recommended'],
181
+
147
182
  airbnb.configs['flat/recommended'],
148
- airbnb.configs['flat/vue'],
183
+ airbnb.configs['flat/addon-vue'],
184
+
185
+ {
186
+ languageOptions: {
187
+ globals: globals.browser,
188
+ },
189
+ }
149
190
  ];
150
191
  ```
151
192
 
@@ -155,12 +196,21 @@ export default [
155
196
  import airbnb from 'eslint-stylistic-airbnb';
156
197
  import pluginVue from 'eslint-plugin-vue';
157
198
  import tseslint from 'typescript-eslint';
199
+ import globals from 'globals';
158
200
 
159
201
  export default [
160
202
  ...tseslint.configs.recommended,
161
203
  ...pluginVue.configs['flat/recommended'],
204
+
162
205
  airbnb.configs['flat/recommended'],
163
- airbnb.configs['flat/vue'],
206
+ airbnb.configs['flat/addon-vue'],
207
+ airbnb.configs['flat/addon-typescript'],
208
+
209
+ {
210
+ languageOptions: {
211
+ globals: globals.browser,
212
+ },
213
+ },
164
214
  ];
165
215
  ```
166
216
 
@@ -204,6 +254,7 @@ Add **any combination** of these to extend base configs:
204
254
 
205
255
  |Config|Dependencies|Description|
206
256
  |-|-|-|
257
+ |`flat/addon-typescript` | `typescript-eslint` | TypeScript-specific rule replacements: replaces base ESLint rules with TypeScript-aware versions for `no-shadow`, `no-unused-vars`, `no-use-before-define`, `no-useless-constructor`, `no-unused-expressions`, `prefer-destructuring`, and `prefer-promise-reject-errors` to prevent incorrect errors. |
207
258
  |`flat/addon-jsx`| None | JSX/TSX formatting for React/Preact/Solid: PascalCase components, double quotes, 2-space indentation, self-closing tags, multiline wrapped in parens, one prop per line (multiline). |
208
259
  |`flat/addoniterators`| None | Relaxes iterator restrictions: allows `for...of` loops. Still disallows `for...in`, `with` statements, and labeled statements. |
209
260
  |`flat/addon-react` | `eslint-plugin-react` | React component rules: prop types validation, no deprecated APIs, component method ordering, lifecycle conventions, no array index keys, destructured props, function component style. |
@@ -259,9 +310,12 @@ import tseslint from 'typescript-eslint';
259
310
  export default [
260
311
  ...tseslint.configs.recommended,
261
312
  airbnb.configs['flat/recommended'],
313
+ airbnb.configs['flat/addon-typescript'],
262
314
  ];
263
315
  ```
264
316
 
317
+ Make sure to include `addon-typescript` to prevent incorrect errors in TypeScript files.
318
+
265
319
  ## Migration Guide
266
320
 
267
321
  ### From `eslint-config-airbnb`
@@ -366,6 +420,32 @@ Yes! See the [Customizing Rules](#customizing-rules) section for examples.
366
420
 
367
421
  Yes, ESLint 9 is fully supported using the flat config format.
368
422
 
423
+ ### Do I need to use a `recommended` config from `@eslint/js`?
424
+
425
+ No, all recommended rules are already included in the base airbnb config. You don't need to add `@eslint/js` recommended preset separately.
426
+
427
+ ### Why do I have `no-undef` errors?
428
+
429
+ Make sure to specify globals via the `languageOptions.globals` property in your flat config. For example, to enable browser globals:
430
+
431
+ ```javascript
432
+ // eslint.config.js
433
+ import airbnb from 'eslint-stylistic-airbnb';
434
+ import globals from 'globals';
435
+
436
+ export default [
437
+ airbnb.configs['flat/recommended'],
438
+
439
+ {
440
+ languageOptions: {
441
+ globals: globals.browser,
442
+ },
443
+ },
444
+ ];
445
+ ```
446
+
447
+ You can also combine multiple environments: `{ ...globals.browser, ...globals.node }`. See the [globals package](https://www.npmjs.com/package/globals) for available options.
448
+
369
449
  ### How do I migrate from `eslint-config-airbnb`?
370
450
 
371
451
  See the [Migration Guide](#migration-guide) for step-by-step instructions.
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ module.exports = {
4
+ name: 'airbnb:addon-typescript',
5
+ rules: {
6
+ 'no-shadow': 'off',
7
+ '@typescript-eslint/no-shadow': 'error',
8
+
9
+ 'no-unused-vars': 'off',
10
+ '@typescript-eslint/no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
11
+
12
+ 'no-use-before-define': 'off',
13
+ '@typescript-eslint/no-use-before-define': ['error', {
14
+ functions: false,
15
+ classes: false,
16
+ variables: true,
17
+ enums: true,
18
+ typedefs: true,
19
+ ignoreTypeReferences: false,
20
+ }],
21
+
22
+ 'no-useless-constructor': 'off',
23
+ '@typescript-eslint/no-useless-constructor': 'error',
24
+
25
+ 'no-unused-expressions': 'off',
26
+ '@typescript-eslint/no-unused-expressions': ['error', {
27
+ allowShortCircuit: false,
28
+ allowTernary: false,
29
+ allowTaggedTemplates: false,
30
+ }],
31
+
32
+ 'prefer-destructuring': 'off',
33
+ '@typescript-eslint/prefer-destructuring': ['error', {
34
+ VariableDeclarator: {
35
+ array: false,
36
+ object: true,
37
+ },
38
+ AssignmentExpression: {
39
+ array: true,
40
+ object: false,
41
+ },
42
+ }, {
43
+ enforceForRenamedProperties: false,
44
+ enforceForDeclarationWithTypeAnnotation: false,
45
+ }],
46
+
47
+ 'prefer-promise-reject-errors': 'off',
48
+ '@typescript-eslint/prefer-promise-reject-errors': ['error', {
49
+ allowEmptyReject: true,
50
+ allowThrowingAny: false,
51
+ allowThrowingUnknown: false,
52
+ }],
53
+ },
54
+ };
package/index.d.ts CHANGED
@@ -14,6 +14,7 @@ declare const airbnb: {
14
14
  'flat/addon-vue': Linter.Config;
15
15
  'flat/addon-vue-ts': Linter.Config;
16
16
  'flat/addon-import': Linter.Config;
17
+ 'flat/addon-typescript': Linter.Config;
17
18
  };
18
19
  };
19
20
 
package/index.js CHANGED
@@ -14,5 +14,6 @@ module.exports = {
14
14
  'flat/addon-vue': require('./configs/flat/addon-vue'),
15
15
  'flat/addon-vue-ts': require('./configs/flat/addon-vue-ts'),
16
16
  'flat/addon-import': require('./configs/flat/addon-import'),
17
+ 'flat/addon-typescript': require('./configs/flat/addon-typescript'),
17
18
  },
18
19
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-stylistic-airbnb",
3
- "version": "3.0.0-rc.1",
3
+ "version": "3.0.0-rc.2",
4
4
  "description": "Airbnb config for eslint using stylistic plugin",
5
5
  "main": "index.js",
6
6
  "types": "./index.d.ts",