@bitfactory/eslint-config 6.3.1 → 7.0.0
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 +4 -4
- package/docs/01-installation.md +2 -3
- package/docs/02-configuration.md +85 -0
- package/docs/04-editor-integration.md +18 -22
- package/docs/migration-typescript-eslint-v8.md +321 -0
- package/{index.flat.js → index.js} +8 -11
- package/package.json +34 -24
- package/rules/{stylistic.flat.js → stylistic.js} +1 -3
- package/{typescript.flat.js → typescript.js} +4 -1
- package/{vue.flat.js → vue.js} +2 -2
- /package/rules/{errors.flat.js → errors.js} +0 -0
- /package/rules/{es6.flat.js → es6.js} +0 -0
- /package/rules/{jsdoc.flat.js → jsdoc.js} +0 -0
- /package/rules/{practices.flat.js → practices.js} +0 -0
- /package/rules/{style.flat.js → style.js} +0 -0
- /package/rules/{variables.flat.js → variables.js} +0 -0
- /package/rules/{vue.flat.js → vue.js} +0 -0
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @bitfactory/eslint-config
|
|
2
2
|
|
|
3
|
-
[](https://github.com/bitfactory-nl/shared-npm-eslint-config-bitfactory)
|
|
4
4
|
[](https://lbesson.mit-license.org/)
|
|
5
|
-
[](https://nodejs.org/)
|
|
5
|
+
[](https://eslint.org/)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
7
|
[](https://github.com/bitfactory-nl/shared-npm-eslint-config-bitfactory/actions/workflows/npm-publish.yml)
|
|
8
8
|
[](https://npmjs.com/package/@bitfactory/eslint-config)
|
|
9
9
|
|
|
@@ -14,7 +14,7 @@ Shareable ESLint config for ESLint v9+ Flat Config (ESM). All rules and configur
|
|
|
14
14
|
>
|
|
15
15
|
> See [Migration Guide Flat Config](docs/migration-flat-config.md) for detailed instructions from v5.x (legacy `.eslintrc.*`) to v6.0.0+ (flat config).
|
|
16
16
|
>
|
|
17
|
-
>
|
|
17
|
+
> Bitfactory ESLint Config v5 with legacy config support (`.eslintrc.*`) is deprecated and no longer supported.
|
|
18
18
|
|
|
19
19
|
- [@bitfactory/eslint-config](#bitfactoryeslint-config)
|
|
20
20
|
- [Quick Start](#quick-start)
|
package/docs/01-installation.md
CHANGED
|
@@ -42,9 +42,8 @@ pnpm add eslint-plugin-vue eslint-plugin-vuejs-accessibility vue-eslint-parser -
|
|
|
42
42
|
|
|
43
43
|
For TypeScript projects, also install:
|
|
44
44
|
|
|
45
|
-
> [!
|
|
46
|
-
>
|
|
47
|
-
> `[p]npm add typescript --save-dev --save-exact`.
|
|
45
|
+
> [!IMPORTANT]
|
|
46
|
+
> **TypeScript-ESLint v8**: Version 7.0.0+ of this config uses TypeScript-ESLint v8, which includes breaking changes and improvements. See the [TypeScript-ESLint v8 Migration Guide](migration-typescript-eslint-v8.md) for details.
|
|
48
47
|
|
|
49
48
|
```bash
|
|
50
49
|
pnpm add @typescript-eslint/eslint-plugin @typescript-eslint/parser --save-dev --save-exact
|
package/docs/02-configuration.md
CHANGED
|
@@ -11,12 +11,34 @@
|
|
|
11
11
|
> [!TIP]
|
|
12
12
|
> Use this configuration for Nuxt 3 and Laravel Inertia projects.
|
|
13
13
|
|
|
14
|
+
**Basic configuration:**
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import bitfactoryBase from '@bitfactory/eslint-config';
|
|
18
|
+
import bitfactoryTypeScript from '@bitfactory/eslint-config/typescript';
|
|
19
|
+
import bitfactoryVue from '@bitfactory/eslint-config/vue';
|
|
20
|
+
import gitignore from 'eslint-config-flat-gitignore';
|
|
21
|
+
import vuePlugin from 'eslint-plugin-vue';
|
|
22
|
+
|
|
23
|
+
export default [
|
|
24
|
+
gitignore(),
|
|
25
|
+
...bitfactoryBase,
|
|
26
|
+
...bitfactoryTypeScript,
|
|
27
|
+
...bitfactoryVue,
|
|
28
|
+
...vuePlugin.configs['flat/vue3-recommended'],
|
|
29
|
+
];
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**With TypeScript parser for `.vue` files** (recommended for `<script lang="ts">`):
|
|
33
|
+
|
|
14
34
|
```js
|
|
15
35
|
import bitfactoryBase from '@bitfactory/eslint-config';
|
|
16
36
|
import bitfactoryTypeScript from '@bitfactory/eslint-config/typescript';
|
|
17
37
|
import bitfactoryVue from '@bitfactory/eslint-config/vue';
|
|
18
38
|
import gitignore from 'eslint-config-flat-gitignore';
|
|
19
39
|
import vuePlugin from 'eslint-plugin-vue';
|
|
40
|
+
import vueParser from 'vue-eslint-parser';
|
|
41
|
+
import tsParser from '@typescript-eslint/parser';
|
|
20
42
|
|
|
21
43
|
export default [
|
|
22
44
|
gitignore(),
|
|
@@ -24,9 +46,22 @@ export default [
|
|
|
24
46
|
...bitfactoryTypeScript,
|
|
25
47
|
...bitfactoryVue,
|
|
26
48
|
...vuePlugin.configs['flat/vue3-recommended'],
|
|
49
|
+
{
|
|
50
|
+
files: ['**/*.vue'],
|
|
51
|
+
languageOptions: {
|
|
52
|
+
parser: vueParser,
|
|
53
|
+
parserOptions: {
|
|
54
|
+
parser: tsParser, // Use TypeScript parser for <script lang="ts">
|
|
55
|
+
extraFileExtensions: ['.vue'],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
27
59
|
];
|
|
28
60
|
```
|
|
29
61
|
|
|
62
|
+
> [!NOTE]
|
|
63
|
+
> The TypeScript parser configuration is required if you use `<script lang="ts">` in your Vue components. Without it, TypeScript-specific linting rules won't work correctly in Vue files.
|
|
64
|
+
|
|
30
65
|
### TypeScript only
|
|
31
66
|
|
|
32
67
|
```js
|
|
@@ -87,3 +122,53 @@ export default [
|
|
|
87
122
|
},
|
|
88
123
|
}
|
|
89
124
|
```
|
|
125
|
+
|
|
126
|
+
### Enable Type-Aware Linting (TypeScript)
|
|
127
|
+
|
|
128
|
+
> [!WARNING]
|
|
129
|
+
> Type-aware linting is significantly slower than regular linting but provides much more thorough error detection. Only enable it if you need the extra type safety and can afford the performance cost.
|
|
130
|
+
|
|
131
|
+
TypeScript-ESLint v8 introduced a stable **Project Service** feature that makes type-aware linting easier to configure:
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import bitfactoryBase from '@bitfactory/eslint-config';
|
|
135
|
+
import bitfactoryTypeScript from '@bitfactory/eslint-config/typescript';
|
|
136
|
+
import gitignore from 'eslint-config-flat-gitignore';
|
|
137
|
+
import tsParser from '@typescript-eslint/parser';
|
|
138
|
+
|
|
139
|
+
export default [
|
|
140
|
+
gitignore(),
|
|
141
|
+
...bitfactoryBase,
|
|
142
|
+
...bitfactoryTypeScript,
|
|
143
|
+
{
|
|
144
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
145
|
+
languageOptions: {
|
|
146
|
+
parser: tsParser,
|
|
147
|
+
parserOptions: {
|
|
148
|
+
projectService: true, // Enable Project Service
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Benefits of type-aware linting:**
|
|
156
|
+
|
|
157
|
+
- Catches type-related errors that basic linting misses
|
|
158
|
+
- Enables advanced rules like `no-floating-promises`, `no-misused-promises`, etc.
|
|
159
|
+
- Automatically locates the nearest `tsconfig.json`
|
|
160
|
+
|
|
161
|
+
**Alternative: Specify tsconfig explicitly:**
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
{
|
|
165
|
+
languageOptions: {
|
|
166
|
+
parser: tsParser,
|
|
167
|
+
parserOptions: {
|
|
168
|
+
project: './tsconfig.json', // Explicit path to tsconfig
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
See the [TypeScript-ESLint v8 Migration Guide](migration-typescript-eslint-v8.md#project-service-type-aware-linting) for more details.
|
|
@@ -46,29 +46,25 @@ Working directory: $ProjectFileDir$
|
|
|
46
46
|
|
|
47
47
|
You can also select JavaScript, Vue.js or TypeScript files for `File type`, and copy the watcher for each needed file to only check those files.
|
|
48
48
|
|
|
49
|
-
Or import the following XML
|
|
49
|
+
Or import the following XML configuration:
|
|
50
50
|
|
|
51
51
|
```xml
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</option>
|
|
65
|
-
<option name="outputFromStdout" value="false" />
|
|
66
|
-
<option name="program" value="$ProjectFileDir$/node_modules/.bin/eslint" />
|
|
67
|
-
<option name="runOnExternalChanges" value="true" />
|
|
68
|
-
<option name="scopeName" value="Project Files" />
|
|
69
|
-
<option name="trackOnlyRoot" value="false" />
|
|
70
|
-
<option name="workingDir" value="$ProjectFileDir$" />
|
|
71
|
-
<envs />
|
|
52
|
+
<project version="4">
|
|
53
|
+
<component name="ProjectTasksOptions">
|
|
54
|
+
<TaskOptions isEnabled="true">
|
|
55
|
+
<option name="name" value="ESLint" />
|
|
56
|
+
<option name="fileExtension" value="js" />
|
|
57
|
+
<option name="scopeName" value="Project Files" />
|
|
58
|
+
<option name="program" value="$ProjectFileDir$/node_modules/.bin/eslint" />
|
|
59
|
+
<option name="arguments" value="--fix $FilePath$" />
|
|
60
|
+
<option name="output" value="$FileDir$" />
|
|
61
|
+
<option name="workingDir" value="$ProjectFileDir$" />
|
|
62
|
+
<option name="immediateSync" value="true" />
|
|
63
|
+
<option name="showConsoleOnError" value="true" />
|
|
72
64
|
</TaskOptions>
|
|
73
|
-
</
|
|
65
|
+
</component>
|
|
66
|
+
</project>
|
|
74
67
|
```
|
|
68
|
+
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> You can change `fileExtension` to `TypeScript` or `Vue.js` to create separate watchers for different file types. You can also set `fileExtension` to `Any` to watch all file types.
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# TypeScript-ESLint v8 Migration Guide
|
|
2
|
+
|
|
3
|
+
Migrating to v7.0.0+ of `@bitfactory/eslint-config` (includes TypeScript-ESLint v8):
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Version 7.0.0 of `@bitfactory/eslint-config` updates TypeScript-ESLint from v7 to v8. TypeScript-ESLint v8 introduces several breaking changes and improvements that enhance type-safety and linting accuracy for TypeScript projects.
|
|
8
|
+
|
|
9
|
+
**Key Changes:**
|
|
10
|
+
|
|
11
|
+
- Several rules have been deprecated and replaced with better alternatives
|
|
12
|
+
- The controversial `ban-types` rule has been split into four targeted rules
|
|
13
|
+
- New type-aware rules provide better error detection
|
|
14
|
+
- Improved performance with the new Project Service feature
|
|
15
|
+
|
|
16
|
+
## What's Changed in This Config
|
|
17
|
+
|
|
18
|
+
### 1. New Rule: `@typescript-eslint/only-throw-error`
|
|
19
|
+
|
|
20
|
+
We've added the new type-aware `@typescript-eslint/only-throw-error` rule and disabled the base ESLint `no-throw-literal` rule for TypeScript files.
|
|
21
|
+
|
|
22
|
+
**Why?** The base `no-throw-literal` rule doesn't understand TypeScript types and can miss errors. The new `@typescript-eslint/only-throw-error` rule uses TypeScript's type system to ensure you only throw Error objects.
|
|
23
|
+
|
|
24
|
+
**Before (ESLint base rule):**
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// Base rule allows this (incorrectly)
|
|
28
|
+
const err = new Error('Something went wrong');
|
|
29
|
+
throw err; // OK
|
|
30
|
+
throw 'error'; // Caught
|
|
31
|
+
throw { message: 'error' }; // Caught
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**After (TypeScript-ESLint v8 rule):**
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// Type-aware rule is smarter
|
|
38
|
+
function getError(): Error | string {
|
|
39
|
+
return Math.random() > 0.5 ? new Error('fail') : 'fail';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
throw getError(); // Now caught! The base rule would miss this.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Rules from `flat/recommended` Preset
|
|
46
|
+
|
|
47
|
+
The `flat/recommended` preset (which this config uses) now includes new rules that replace `ban-types`:
|
|
48
|
+
|
|
49
|
+
- `@typescript-eslint/no-empty-object-type` - Prevents confusing use of `{}`
|
|
50
|
+
- `@typescript-eslint/no-unsafe-function-type` - Bans the overly broad `Function` type
|
|
51
|
+
- `@typescript-eslint/no-wrapper-object-types` - Bans `Object`, `Number`, `String`, etc.
|
|
52
|
+
- `@typescript-eslint/no-restricted-types` - Configurable type bans (no defaults)
|
|
53
|
+
|
|
54
|
+
These rules are automatically enabled and provide more granular control than the old `ban-types` rule.
|
|
55
|
+
|
|
56
|
+
## Migration Steps
|
|
57
|
+
|
|
58
|
+
### If You're Already on v7.0.0+
|
|
59
|
+
|
|
60
|
+
No action required! Your configuration already includes TypeScript-ESLint v8.
|
|
61
|
+
|
|
62
|
+
### If You're Upgrading from v6.x or Earlier
|
|
63
|
+
|
|
64
|
+
1. **Update to v7.0.0**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Using pnpm (recommended)
|
|
68
|
+
pnpm add @bitfactory/eslint-config@^7.0.0 --save-dev --save-exact
|
|
69
|
+
|
|
70
|
+
# Using npm
|
|
71
|
+
npm install @bitfactory/eslint-config@^7.0.0 --save-dev --save-exact
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
2. **Update peer dependencies**
|
|
75
|
+
|
|
76
|
+
If your project doesn't use `.npmrc` with `auto-install-peers=true`, update peer dependencies:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Using pnpm
|
|
80
|
+
pnpm dlx install-peerdeps --dev --extra-args="-E" @bitfactory/eslint-config
|
|
81
|
+
|
|
82
|
+
# Using npm
|
|
83
|
+
npx install-peerdeps --dev --extra-args="-E" @bitfactory/eslint-config
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This will install:
|
|
87
|
+
- `@typescript-eslint/eslint-plugin@>=8.0.0`
|
|
88
|
+
- `@typescript-eslint/parser@>=8.0.0`
|
|
89
|
+
- Other required peer dependencies
|
|
90
|
+
|
|
91
|
+
3. **Review your custom TypeScript rules**
|
|
92
|
+
|
|
93
|
+
If you have custom overrides in your `eslint.config.js`, check for deprecated rules:
|
|
94
|
+
|
|
95
|
+
**Deprecated Rules** (replace these if you're using them):
|
|
96
|
+
|
|
97
|
+
| Old Rule | New Rule |
|
|
98
|
+
|----------|----------|
|
|
99
|
+
| `@typescript-eslint/prefer-ts-expect-error` | `@typescript-eslint/ban-ts-comment` |
|
|
100
|
+
| `@typescript-eslint/no-var-requires` | `@typescript-eslint/no-require-imports` |
|
|
101
|
+
| `@typescript-eslint/no-throw-literal` | `@typescript-eslint/only-throw-error` |
|
|
102
|
+
| `@typescript-eslint/ban-types` | Split into 4 rules (see above) |
|
|
103
|
+
|
|
104
|
+
**Example - Before:**
|
|
105
|
+
|
|
106
|
+
```javascript
|
|
107
|
+
export default [
|
|
108
|
+
...bitfactoryTypeScript,
|
|
109
|
+
{
|
|
110
|
+
files: ['**/*.ts'],
|
|
111
|
+
rules: {
|
|
112
|
+
'@typescript-eslint/no-throw-literal': 'error', // Deprecated
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Example - After:**
|
|
119
|
+
|
|
120
|
+
```javascript
|
|
121
|
+
export default [
|
|
122
|
+
...bitfactoryTypeScript,
|
|
123
|
+
{
|
|
124
|
+
files: ['**/*.ts'],
|
|
125
|
+
rules: {
|
|
126
|
+
'@typescript-eslint/only-throw-error': 'error', // New rule
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
4. **Test your configuration**
|
|
133
|
+
|
|
134
|
+
Run ESLint to check for any new errors from the updated rules:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Using pnpm
|
|
138
|
+
pnpm run lint
|
|
139
|
+
|
|
140
|
+
# Using npm
|
|
141
|
+
npm run lint
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Some code that was previously allowed may now be flagged. These are typically genuine issues that TypeScript-ESLint v8 can now detect.
|
|
145
|
+
|
|
146
|
+
## Common Migration Issues
|
|
147
|
+
|
|
148
|
+
### Issue 1: New Errors from `only-throw-error`
|
|
149
|
+
|
|
150
|
+
**Problem:** Code that throws non-Error values is now detected:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
// Now flagged as error
|
|
154
|
+
async function fetchData() {
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
throw response.statusText; // String instead of Error
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Solution:** Throw proper Error objects:
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
async function fetchData() {
|
|
165
|
+
if (!response.ok) {
|
|
166
|
+
throw new Error(response.statusText); // Proper Error object
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Issue 2: Empty Object Type `{}`
|
|
172
|
+
|
|
173
|
+
**Problem:** The `{}` type in certain contexts is now flagged:
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// Now flagged
|
|
177
|
+
function acceptAnything(value: {}) {
|
|
178
|
+
// ...
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Solution:** Use a more specific type:
|
|
183
|
+
|
|
184
|
+
```typescript
|
|
185
|
+
// Use object for non-null objects
|
|
186
|
+
function acceptAnything(value: object) {
|
|
187
|
+
// ...
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Or use unknown for truly anything
|
|
191
|
+
function acceptAnything(value: unknown) {
|
|
192
|
+
// ...
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Or use Record for key-value objects
|
|
196
|
+
function acceptAnything(value: Record<string, unknown>) {
|
|
197
|
+
// ...
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Issue 3: `Function` Type
|
|
202
|
+
|
|
203
|
+
**Problem:** The overly broad `Function` type is now disallowed:
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
// Now flagged
|
|
207
|
+
function callCallback(callback: Function) {
|
|
208
|
+
callback();
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**Solution:** Use a specific function signature:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// Better: specific signature
|
|
216
|
+
function callCallback(callback: () => void) {
|
|
217
|
+
callback();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// Or use a generic if you need flexibility
|
|
221
|
+
function callCallback<T extends (...args: any[]) => any>(callback: T) {
|
|
222
|
+
callback();
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## New Features You Can Adopt
|
|
227
|
+
|
|
228
|
+
### Project Service (Type-Aware Linting)
|
|
229
|
+
|
|
230
|
+
TypeScript-ESLint v8 introduces a stable Project Service feature that makes type-aware linting easier and faster.
|
|
231
|
+
|
|
232
|
+
**To enable type-aware linting in your project:**
|
|
233
|
+
|
|
234
|
+
```javascript
|
|
235
|
+
import bitfactoryTypeScript from '@bitfactory/eslint-config/typescript';
|
|
236
|
+
import tsParser from '@typescript-eslint/parser';
|
|
237
|
+
|
|
238
|
+
export default [
|
|
239
|
+
...bitfactoryTypeScript,
|
|
240
|
+
{
|
|
241
|
+
files: ['**/*.ts', '**/*.tsx'],
|
|
242
|
+
languageOptions: {
|
|
243
|
+
parser: tsParser,
|
|
244
|
+
parserOptions: {
|
|
245
|
+
projectService: true, // Enable Project Service
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Benefits:**
|
|
253
|
+
|
|
254
|
+
- Automatically locates the nearest `tsconfig.json`
|
|
255
|
+
- Better performance than traditional project configuration
|
|
256
|
+
- Supports out-of-project files
|
|
257
|
+
|
|
258
|
+
**Note:** Type-aware linting is slower but provides much more thorough error detection. Enable it if your project can afford the extra lint time.
|
|
259
|
+
|
|
260
|
+
## Vue + TypeScript Projects
|
|
261
|
+
|
|
262
|
+
If you're using Vue with TypeScript (`<script lang="ts">`), you need to configure the parser correctly:
|
|
263
|
+
|
|
264
|
+
```javascript
|
|
265
|
+
import bitfactoryVue from '@bitfactory/eslint-config/vue';
|
|
266
|
+
import vueParser from 'vue-eslint-parser';
|
|
267
|
+
import tsParser from '@typescript-eslint/parser';
|
|
268
|
+
|
|
269
|
+
export default [
|
|
270
|
+
...bitfactoryVue,
|
|
271
|
+
{
|
|
272
|
+
files: ['**/*.vue'],
|
|
273
|
+
languageOptions: {
|
|
274
|
+
parser: vueParser,
|
|
275
|
+
parserOptions: {
|
|
276
|
+
parser: tsParser, // Use TypeScript parser for <script lang="ts">
|
|
277
|
+
extraFileExtensions: ['.vue'],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
];
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
See [Configuration Examples](02-configuration.md#vue-3--typescript) for more details.
|
|
285
|
+
|
|
286
|
+
## Version Requirements
|
|
287
|
+
|
|
288
|
+
To use v7.0.0 of this config, you need:
|
|
289
|
+
|
|
290
|
+
- **Node.js:** `^20.9.0 || ^22.11.0 || ^24.11.0`
|
|
291
|
+
- **ESLint:** `^9.29.0`
|
|
292
|
+
- **TypeScript-ESLint:** `>=8.0.0`
|
|
293
|
+
- **TypeScript:** `>=4.8.4` (recommended: latest 5.x)
|
|
294
|
+
|
|
295
|
+
## Additional Resources
|
|
296
|
+
|
|
297
|
+
- [TypeScript-ESLint v8 Announcement](https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/)
|
|
298
|
+
- [TypeScript-ESLint Rules Documentation](https://typescript-eslint.io/rules/)
|
|
299
|
+
- [Configuration Guide](02-configuration.md)
|
|
300
|
+
- [Flat Config Migration Guide](migration-flat-config.md)
|
|
301
|
+
|
|
302
|
+
## Need Help?
|
|
303
|
+
|
|
304
|
+
If you encounter issues during migration:
|
|
305
|
+
|
|
306
|
+
1. Check the [TypeScript-ESLint v8 announcement](https://typescript-eslint.io/blog/announcing-typescript-eslint-v8/) for detailed breaking change information
|
|
307
|
+
2. Review your custom rules against the deprecated rules list above
|
|
308
|
+
3. Run ESLint with `--debug` flag to see detailed error messages
|
|
309
|
+
4. Check the [Configuration Guide](02-configuration.md) for examples
|
|
310
|
+
|
|
311
|
+
## Summary
|
|
312
|
+
|
|
313
|
+
TypeScript-ESLint v8 brings significant improvements to type-safety and linting accuracy. While there are breaking changes, the migration is straightforward for most projects. The new rules help catch more bugs and the improved performance makes type-aware linting more accessible.
|
|
314
|
+
|
|
315
|
+
**Quick checklist:**
|
|
316
|
+
|
|
317
|
+
- Update to v7.0.0 of this config
|
|
318
|
+
- Update peer dependencies (especially TypeScript-ESLint packages)
|
|
319
|
+
- Review and update any deprecated rules in your custom config
|
|
320
|
+
- Test your configuration
|
|
321
|
+
- Fix any new errors (they're usually real issues!)
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// ESLint Flat Config for @bitfactory/eslint-config
|
|
2
|
-
// This file is for ESLint v9+ flat config support. The legacy config files remain for backward compatibility.
|
|
3
|
-
|
|
4
1
|
import js from '@eslint/js';
|
|
5
2
|
import stylistic from '@stylistic/eslint-plugin';
|
|
6
3
|
import jsdoc from 'eslint-plugin-jsdoc';
|
|
@@ -9,13 +6,13 @@ import importPlugin from 'eslint-plugin-import';
|
|
|
9
6
|
import babelParser from '@babel/eslint-parser';
|
|
10
7
|
import globals from 'globals';
|
|
11
8
|
|
|
12
|
-
import { errorsRules } from './rules/errors.
|
|
13
|
-
import { es6Rules } from './rules/es6.
|
|
14
|
-
import { jsdocRules } from './rules/jsdoc.
|
|
15
|
-
import { practicesRules } from './rules/practices.
|
|
16
|
-
import { styleRules } from './rules/style.
|
|
17
|
-
import { stylisticRules } from './rules/stylistic.
|
|
18
|
-
import { variablesRules } from './rules/variables.
|
|
9
|
+
import { errorsRules } from './rules/errors.js';
|
|
10
|
+
import { es6Rules } from './rules/es6.js';
|
|
11
|
+
import { jsdocRules } from './rules/jsdoc.js';
|
|
12
|
+
import { practicesRules } from './rules/practices.js';
|
|
13
|
+
import { styleRules } from './rules/style.js';
|
|
14
|
+
import { stylisticRules } from './rules/stylistic.js';
|
|
15
|
+
import { variablesRules } from './rules/variables.js';
|
|
19
16
|
|
|
20
17
|
export default [
|
|
21
18
|
{
|
|
@@ -26,7 +23,7 @@ export default [
|
|
|
26
23
|
'/static/sw.*',
|
|
27
24
|
],
|
|
28
25
|
},
|
|
29
|
-
stylistic.configs
|
|
26
|
+
stylistic.configs.recommended,
|
|
30
27
|
{
|
|
31
28
|
files: ['**/*.{js,mjs}'],
|
|
32
29
|
linterOptions: {
|
package/package.json
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitfactory/eslint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "ESLint sharable config for Bitfactory projects",
|
|
3
|
+
"version": "7.0.0",
|
|
4
|
+
"description": "ESLint sharable config for Bitfactory NL (part of NOBEARS) projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
7
|
-
"eslintconfig"
|
|
7
|
+
"eslintconfig",
|
|
8
|
+
"eslint-config",
|
|
9
|
+
"flat-config",
|
|
10
|
+
"javascript",
|
|
11
|
+
"typescript",
|
|
12
|
+
"vue",
|
|
13
|
+
"code-quality",
|
|
14
|
+
"linting",
|
|
15
|
+
"stylistic"
|
|
8
16
|
],
|
|
9
17
|
"repository": "https://github.com/Bitfactory-NL/shared-npm-eslint-config-bitfactory",
|
|
10
18
|
"license": "MIT",
|
|
11
|
-
"author": "Bitfactory",
|
|
19
|
+
"author": "Bitfactory NL (part of NOBEARS)",
|
|
12
20
|
"type": "module",
|
|
13
21
|
"exports": {
|
|
14
|
-
".": "./index.
|
|
15
|
-
"./typescript": "./typescript.
|
|
16
|
-
"./vue": "./vue.
|
|
17
|
-
"./typescript.flat.js": "./typescript.flat.js",
|
|
18
|
-
"./vue.flat.js": "./vue.flat.js"
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./typescript": "./typescript.js",
|
|
24
|
+
"./vue": "./vue.js"
|
|
19
25
|
},
|
|
20
|
-
"main": "index.
|
|
26
|
+
"main": "index.js",
|
|
21
27
|
"directories": {
|
|
22
28
|
"doc": "docs"
|
|
23
29
|
},
|
|
24
30
|
"files": [
|
|
25
31
|
"docs",
|
|
26
32
|
"rules",
|
|
27
|
-
"index.
|
|
28
|
-
"typescript.
|
|
29
|
-
"vue.
|
|
33
|
+
"index.js",
|
|
34
|
+
"typescript.js",
|
|
35
|
+
"vue.js",
|
|
30
36
|
"README.md",
|
|
31
37
|
"QUICKSTART.md"
|
|
32
38
|
],
|
|
@@ -39,19 +45,20 @@
|
|
|
39
45
|
"peerDependencies": {
|
|
40
46
|
"@babel/core": ">=7.26.10",
|
|
41
47
|
"@babel/eslint-parser": ">=7.26.10",
|
|
42
|
-
"@eslint/js": "^9.
|
|
43
|
-
"@stylistic/eslint-plugin": ">=
|
|
44
|
-
"@typescript-eslint/eslint-plugin": ">=
|
|
45
|
-
"@typescript-eslint/parser": ">=
|
|
46
|
-
"eslint": "^9.
|
|
48
|
+
"@eslint/js": "^9.29.0",
|
|
49
|
+
"@stylistic/eslint-plugin": ">=4.0.0",
|
|
50
|
+
"@typescript-eslint/eslint-plugin": ">=8.0.0",
|
|
51
|
+
"@typescript-eslint/parser": ">=8.0.0",
|
|
52
|
+
"eslint": "^9.29.0",
|
|
47
53
|
"eslint-config-flat-gitignore": "^2.0.0",
|
|
48
54
|
"eslint-plugin-import": ">=2.31.0",
|
|
49
|
-
"eslint-plugin-jsdoc": ">=
|
|
50
|
-
"eslint-plugin-unicorn": ">=
|
|
51
|
-
"eslint-plugin-vue": ">=
|
|
52
|
-
"eslint-plugin-vuejs-accessibility": ">=0.
|
|
53
|
-
"globals": ">=
|
|
54
|
-
"
|
|
55
|
+
"eslint-plugin-jsdoc": ">=48.0.0",
|
|
56
|
+
"eslint-plugin-unicorn": ">=60.0.0 <62.0.0",
|
|
57
|
+
"eslint-plugin-vue": ">=10.0.0",
|
|
58
|
+
"eslint-plugin-vuejs-accessibility": ">=1.0.0",
|
|
59
|
+
"globals": ">=15.0.0",
|
|
60
|
+
"typescript": ">=4.8.4",
|
|
61
|
+
"vue-eslint-parser": ">=10.1.1"
|
|
55
62
|
},
|
|
56
63
|
"peerDependenciesMeta": {
|
|
57
64
|
"@typescript-eslint/eslint-plugin": {
|
|
@@ -66,6 +73,9 @@
|
|
|
66
73
|
"eslint-plugin-vuejs-accessibility": {
|
|
67
74
|
"optional": true
|
|
68
75
|
},
|
|
76
|
+
"typescript": {
|
|
77
|
+
"optional": true
|
|
78
|
+
},
|
|
69
79
|
"vue-eslint-parser": {
|
|
70
80
|
"optional": true
|
|
71
81
|
}
|
|
@@ -38,7 +38,6 @@ export const stylisticRules = {
|
|
|
38
38
|
multilineDetection: 'brackets',
|
|
39
39
|
}],
|
|
40
40
|
'@stylistic/multiline-comment-style': ['error', 'separate-lines'],
|
|
41
|
-
'@stylistic/multiline-ternary': ['error', 'never'],
|
|
42
41
|
'@stylistic/new-parens': 'error',
|
|
43
42
|
'@stylistic/newline-per-chained-call': 'error',
|
|
44
43
|
'@stylistic/no-confusing-arrow': 'error',
|
|
@@ -73,7 +72,6 @@ export const stylisticRules = {
|
|
|
73
72
|
'@stylistic/object-curly-spacing': ['error', 'always'],
|
|
74
73
|
'@stylistic/object-property-newline': 'error',
|
|
75
74
|
'@stylistic/one-var-declaration-per-line': ['error', 'always'],
|
|
76
|
-
'@stylistic/operator-linebreak': ['error', 'after'],
|
|
77
75
|
'@stylistic/padding-line-between-statements': ['error', {
|
|
78
76
|
blankLine: 'always',
|
|
79
77
|
next: 'return',
|
|
@@ -82,7 +80,7 @@ export const stylisticRules = {
|
|
|
82
80
|
'@stylistic/rest-spread-spacing': 'error',
|
|
83
81
|
'@stylistic/quote-props': ['error', 'consistent-as-needed'],
|
|
84
82
|
'@stylistic/quotes': ['error', 'single', {
|
|
85
|
-
allowTemplateLiterals:
|
|
83
|
+
allowTemplateLiterals: 'never',
|
|
86
84
|
avoidEscape: true,
|
|
87
85
|
}],
|
|
88
86
|
'@stylistic/semi': ['error', 'always'],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import baseConfig from './index.
|
|
1
|
+
import baseConfig from './index.js';
|
|
2
2
|
import ts from '@typescript-eslint/eslint-plugin';
|
|
3
3
|
import tsParser from '@typescript-eslint/parser';
|
|
4
4
|
|
|
@@ -25,6 +25,9 @@ export default [
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
'no-duplicate-imports': 'off',
|
|
28
|
+
// Use type-aware rule instead of base ESLint rule for better error detection
|
|
29
|
+
'no-throw-literal': 'off',
|
|
30
|
+
'@typescript-eslint/only-throw-error': 'error',
|
|
28
31
|
},
|
|
29
32
|
},
|
|
30
33
|
];
|
package/{vue.flat.js → vue.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import baseConfig from './index.
|
|
1
|
+
import baseConfig from './index.js';
|
|
2
2
|
import vue from 'eslint-plugin-vue';
|
|
3
3
|
import vueA11y from 'eslint-plugin-vuejs-accessibility';
|
|
4
4
|
import vueParser from 'vue-eslint-parser';
|
|
5
5
|
import babelParser from '@babel/eslint-parser';
|
|
6
|
-
import { vueRules } from './rules/vue.
|
|
6
|
+
import { vueRules } from './rules/vue.js';
|
|
7
7
|
|
|
8
8
|
export default [
|
|
9
9
|
...baseConfig,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|