@szum-tech/eslint-config 2.1.15 → 2.2.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 +44 -35
- package/dist/index.cjs +40 -50
- package/dist/index.d.cts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +38 -30
- package/package.json +16 -13
package/README.md
CHANGED
|
@@ -19,11 +19,16 @@
|
|
|
19
19
|
A shared configuration is an NPM package that exports a configuration as an array. It's super convenient for anyone to
|
|
20
20
|
use, because the configuration dynamically adapts to the needs of the project.
|
|
21
21
|
|
|
22
|
+
**✨ Ready for ESLint v10!** This configuration uses the modern flat config format and is compatible with ESLint v9.x. Full ESLint v10 support will be added once the ecosystem plugins (especially typescript-eslint) release compatible versions.
|
|
23
|
+
|
|
22
24
|
## 📚 Features
|
|
23
25
|
|
|
24
|
-
- [
|
|
26
|
+
- **[ESLint v9](https://eslint.org/)** - Latest stable version with full plugin ecosystem support (ready for v10 migration)
|
|
27
|
+
- **Flat Config Format** - Uses the modern `eslint.config.js` format (legacy `.eslintrc` is not supported)
|
|
28
|
+
- **Auto-detection** - Automatically enables plugins based on your project dependencies
|
|
29
|
+
- [Opinionated code formatter with support for: JavaScript, TypeScript, JSX, ...](https://eslint.org/)
|
|
25
30
|
- [Support linting of ES2015+ (ES6+) import/export syntax, and prevent issues with misspelling of file paths and import names](https://www.npmjs.com/package/eslint-plugin-import)
|
|
26
|
-
- [
|
|
31
|
+
- [TypeScript support](https://typescript-eslint.io/packages/typescript-eslint/) - **only** if
|
|
27
32
|
[typescript](https://www.npmjs.com/package/typescript) is used in project
|
|
28
33
|
- [React](https://www.npmjs.com/package/eslint-plugin-react) &
|
|
29
34
|
[React Hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) specific linting rules - **only** if
|
|
@@ -67,52 +72,56 @@ use, because the configuration dynamically adapts to the needs of the project.
|
|
|
67
72
|
[@szum-tech/eslint-config](https://github.com/JanSzewczyk/eslint-config) is available as
|
|
68
73
|
[npm package](https://www.npmjs.com/package/@szum-tech/eslint-config).
|
|
69
74
|
|
|
75
|
+
**Requirements:**
|
|
76
|
+
- **ESLint** v9.0.0 or higher
|
|
77
|
+
- **Node.js** v20.x+ / v22.x+ / v24.x+
|
|
78
|
+
|
|
70
79
|
```shell
|
|
71
80
|
# NPM
|
|
72
|
-
npm install --save-dev eslint @szum-tech/eslint-config
|
|
81
|
+
npm install --save-dev eslint@latest @szum-tech/eslint-config
|
|
73
82
|
|
|
74
83
|
# YARN
|
|
75
|
-
yarn add -D eslint @szum-tech/eslint-config
|
|
84
|
+
yarn add -D eslint@latest @szum-tech/eslint-config
|
|
76
85
|
|
|
77
86
|
# PNPM
|
|
78
|
-
pnpm add --save-dev eslint @szum-tech/eslint-config
|
|
87
|
+
pnpm add --save-dev eslint@latest @szum-tech/eslint-config
|
|
79
88
|
|
|
80
89
|
# BUN
|
|
81
|
-
bun add --dev eslint @szum-tech/eslint-config
|
|
90
|
+
bun add --dev eslint@latest @szum-tech/eslint-config
|
|
82
91
|
```
|
|
83
92
|
|
|
84
93
|
### Configuration
|
|
85
94
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
A `@szum-tech/eslint-config` is an npm package that exports a configuration object or array.
|
|
95
|
+
This package uses the [ESLint Flat Config format](https://eslint.org/docs/latest/use/configure/configuration-files)
|
|
96
|
+
introduced in ESLint v9 and required in ESLint v10. The legacy `.eslintrc` format is not supported.
|
|
90
97
|
|
|
91
|
-
|
|
98
|
+
A `@szum-tech/eslint-config` is an npm package that exports a configuration array that automatically adapts to your
|
|
99
|
+
project's dependencies.
|
|
92
100
|
|
|
93
|
-
|
|
101
|
+
**Configuration file: `eslint.config.(js|cjs|mjs)`**
|
|
94
102
|
|
|
95
|
-
|
|
103
|
+
#### Simple Usage
|
|
96
104
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Once you use a predefined configuration, you can export the entire configuration.
|
|
105
|
+
Export the entire configuration as-is:
|
|
100
106
|
|
|
101
107
|
```js
|
|
108
|
+
// eslint.config.mjs
|
|
102
109
|
export { default } from "@szum-tech/eslint-config";
|
|
103
110
|
```
|
|
104
111
|
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
#### Extended Configuration
|
|
113
|
+
|
|
114
|
+
`@szum-tech/eslint-config` is flexible enough to allow for configuration extensions. Use the spread operator to insert
|
|
115
|
+
the configuration into your array:
|
|
107
116
|
|
|
108
117
|
```js
|
|
109
|
-
// eslint.config.
|
|
118
|
+
// eslint.config.mjs
|
|
110
119
|
import szumTechEslintConfig from "@szum-tech/eslint-config";
|
|
111
120
|
|
|
112
121
|
export default [
|
|
113
122
|
...szumTechEslintConfig,
|
|
114
123
|
|
|
115
|
-
//
|
|
124
|
+
// Your custom modifications
|
|
116
125
|
{
|
|
117
126
|
rules: {
|
|
118
127
|
"no-unused-vars": "warn"
|
|
@@ -121,21 +130,18 @@ export default [
|
|
|
121
130
|
];
|
|
122
131
|
```
|
|
123
132
|
|
|
124
|
-
|
|
133
|
+
#### CommonJS Format
|
|
125
134
|
|
|
126
|
-
|
|
127
|
-
module.exports = require("@szum-tech/semantic-release-config/with-npm");
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
OR, extends
|
|
135
|
+
For projects using CommonJS:
|
|
131
136
|
|
|
132
137
|
```js
|
|
133
|
-
|
|
138
|
+
// eslint.config.cjs
|
|
139
|
+
const szumTechEslintConfig = require("@szum-tech/eslint-config");
|
|
134
140
|
|
|
135
141
|
module.exports = [
|
|
136
142
|
...szumTechEslintConfig,
|
|
137
143
|
|
|
138
|
-
//
|
|
144
|
+
// Your custom modifications
|
|
139
145
|
{
|
|
140
146
|
rules: {
|
|
141
147
|
"no-unused-vars": "warn"
|
|
@@ -144,6 +150,9 @@ module.exports = [
|
|
|
144
150
|
];
|
|
145
151
|
```
|
|
146
152
|
|
|
153
|
+
> **Note:** The configuration automatically detects which libraries are installed in your project (React, TypeScript,
|
|
154
|
+
> Next.js, Vitest, etc.) and enables the appropriate ESLint plugins and rules.
|
|
155
|
+
|
|
147
156
|
## 💻 Scripts
|
|
148
157
|
|
|
149
158
|
Suggested scripts you can add to `package.json` file:
|
|
@@ -168,11 +177,11 @@ Suggested scripts you can add to `package.json` file:
|
|
|
168
177
|
- `lint:inspect`: Launches a visual representation of the ESLint configuration file (check http://localhost:7777 in your
|
|
169
178
|
browser). Allows you to navigate through the rules, plugins, and language configurations that are enabled or disabled
|
|
170
179
|
|
|
171
|
-
## 🚀 Minimal GitHub
|
|
180
|
+
## 🚀 Minimal GitHub ESLint check workflow
|
|
172
181
|
|
|
173
|
-
Here are the minimal steps required to run an
|
|
182
|
+
Here are the minimal steps required to run an ESLint check. Creating or adding any content to a PR will trigger this
|
|
174
183
|
event. Not only will this action validate the code and return its results, but it will also add highlighted parts of the
|
|
175
|
-
code that have an error to the comments under the PR thanks to the `Upload
|
|
184
|
+
code that have an error to the comments under the PR thanks to the `Upload ESLint results to GitHub` step, which uses
|
|
176
185
|
`github/codeql-action/upload-sarif`.
|
|
177
186
|
|
|
178
187
|
```yaml
|
|
@@ -183,11 +192,11 @@ on:
|
|
|
183
192
|
|
|
184
193
|
jobs:
|
|
185
194
|
lint:
|
|
186
|
-
name:
|
|
195
|
+
name: ESLint ⬣
|
|
187
196
|
runs-on: ${{ matrix.os }}
|
|
188
197
|
strategy:
|
|
189
198
|
matrix:
|
|
190
|
-
node-version: [
|
|
199
|
+
node-version: [24.x] # Use Node.js 20+, 22+, or 24+
|
|
191
200
|
os: [ubuntu-latest]
|
|
192
201
|
steps:
|
|
193
202
|
- name: Checkout code 📚
|
|
@@ -199,10 +208,10 @@ jobs:
|
|
|
199
208
|
cache: "npm"
|
|
200
209
|
- name: Install dependencies ⚙️
|
|
201
210
|
run: npm ci
|
|
202
|
-
- name:
|
|
211
|
+
- name: ESLint Check ⬣
|
|
203
212
|
run: npm run lint:ci
|
|
204
213
|
continue-on-error: true
|
|
205
|
-
- name: Upload
|
|
214
|
+
- name: Upload ESLint results to GitHub
|
|
206
215
|
uses: github/codeql-action/upload-sarif@v3
|
|
207
216
|
with:
|
|
208
217
|
sarif_file: eslint-results.sarif
|
package/dist/index.cjs
CHANGED
|
@@ -8,7 +8,6 @@ var playwrightPlugin = require('eslint-plugin-playwright');
|
|
|
8
8
|
var reactPlugin = require('eslint-plugin-react');
|
|
9
9
|
var reactHooksPlugin = require('eslint-plugin-react-hooks');
|
|
10
10
|
var storybookPlugin = require('eslint-plugin-storybook');
|
|
11
|
-
require('eslint-plugin-tailwindcss');
|
|
12
11
|
var testingLibraryPlugin = require('eslint-plugin-testing-library');
|
|
13
12
|
var globals = require('globals');
|
|
14
13
|
var tsEslint = require('typescript-eslint');
|
|
@@ -17,29 +16,11 @@ var vitestPlugin = require('@vitest/eslint-plugin');
|
|
|
17
16
|
|
|
18
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
if (e && e.__esModule) return e;
|
|
22
|
-
var n = Object.create(null);
|
|
23
|
-
if (e) {
|
|
24
|
-
Object.keys(e).forEach(function (k) {
|
|
25
|
-
if (k !== 'default') {
|
|
26
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return e[k]; }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
n.default = e;
|
|
35
|
-
return Object.freeze(n);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var importPlugin__namespace = /*#__PURE__*/_interopNamespace(importPlugin);
|
|
19
|
+
var importPlugin__default = /*#__PURE__*/_interopDefault(importPlugin);
|
|
39
20
|
var jestDomPlugin__default = /*#__PURE__*/_interopDefault(jestDomPlugin);
|
|
40
21
|
var playwrightPlugin__default = /*#__PURE__*/_interopDefault(playwrightPlugin);
|
|
41
22
|
var reactPlugin__default = /*#__PURE__*/_interopDefault(reactPlugin);
|
|
42
|
-
var
|
|
23
|
+
var reactHooksPlugin__default = /*#__PURE__*/_interopDefault(reactHooksPlugin);
|
|
43
24
|
var storybookPlugin__default = /*#__PURE__*/_interopDefault(storybookPlugin);
|
|
44
25
|
var testingLibraryPlugin__default = /*#__PURE__*/_interopDefault(testingLibraryPlugin);
|
|
45
26
|
var globals__default = /*#__PURE__*/_interopDefault(globals);
|
|
@@ -47,17 +28,21 @@ var tsEslint__default = /*#__PURE__*/_interopDefault(tsEslint);
|
|
|
47
28
|
var nextPlugin__default = /*#__PURE__*/_interopDefault(nextPlugin);
|
|
48
29
|
var vitestPlugin__default = /*#__PURE__*/_interopDefault(vitestPlugin);
|
|
49
30
|
|
|
50
|
-
// src/index.
|
|
31
|
+
// src/index.ts
|
|
51
32
|
var logger = console;
|
|
52
33
|
function isPackageInstalled(packageName) {
|
|
53
34
|
const currentDir = process.cwd();
|
|
54
35
|
const packageJsonPath = findPackageJson(currentDir);
|
|
36
|
+
if (!packageJsonPath) {
|
|
37
|
+
logger.error("Could not find package.json in", currentDir, "or any parent directory.");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
55
40
|
try {
|
|
56
41
|
const packageJson = fs.readFileSync(packageJsonPath, "utf-8");
|
|
57
42
|
const parsedPackageJson = JSON.parse(packageJson);
|
|
58
43
|
const dependencies = parsedPackageJson.dependencies || {};
|
|
59
44
|
const devDependencies = parsedPackageJson.devDependencies || {};
|
|
60
|
-
return
|
|
45
|
+
return packageName in dependencies || packageName in devDependencies;
|
|
61
46
|
} catch (error) {
|
|
62
47
|
logger.error("Error reading package.json file:", error);
|
|
63
48
|
process.exit(1);
|
|
@@ -144,7 +129,7 @@ var config = [
|
|
|
144
129
|
{
|
|
145
130
|
name: "eslint/config/base&import",
|
|
146
131
|
plugins: {
|
|
147
|
-
import:
|
|
132
|
+
import: importPlugin__default.default
|
|
148
133
|
},
|
|
149
134
|
languageOptions: {
|
|
150
135
|
ecmaVersion: "latest",
|
|
@@ -220,7 +205,7 @@ var config = [
|
|
|
220
205
|
files: ["**/*.tsx", "**/*.jsx"],
|
|
221
206
|
plugins: {
|
|
222
207
|
react: reactPlugin__default.default,
|
|
223
|
-
"react-hooks":
|
|
208
|
+
"react-hooks": reactHooksPlugin__default.default
|
|
224
209
|
},
|
|
225
210
|
languageOptions: {
|
|
226
211
|
parser: tsEslint__default.default.parser,
|
|
@@ -258,7 +243,32 @@ var config = [
|
|
|
258
243
|
"react-hooks/exhaustive-deps": WARN
|
|
259
244
|
}
|
|
260
245
|
} : null,
|
|
261
|
-
|
|
246
|
+
// TODO add when support for tailwindcss v4 will be added
|
|
247
|
+
// hasTailwindcss
|
|
248
|
+
// ? {
|
|
249
|
+
// name: "eslint/config/tailwindcss",
|
|
250
|
+
// plugins: {
|
|
251
|
+
// tailwindcss: tailwindcssPlugin
|
|
252
|
+
// },
|
|
253
|
+
// languageOptions: {
|
|
254
|
+
// parserOptions: {
|
|
255
|
+
// ecmaFeatures: {
|
|
256
|
+
// jsx: true
|
|
257
|
+
// }
|
|
258
|
+
// }
|
|
259
|
+
// },
|
|
260
|
+
// rules: {
|
|
261
|
+
// "tailwindcss/no-contradicting-classname": ERROR,
|
|
262
|
+
// "tailwindcss/classnames-order": WARN,
|
|
263
|
+
// "tailwindcss/enforces-negative-arbitrary-values": WARN,
|
|
264
|
+
// "tailwindcss/enforces-shorthand": WARN,
|
|
265
|
+
// "tailwindcss/migration-from-tailwind-2": WARN,
|
|
266
|
+
// "tailwindcss/no-custom-classname": WARN,
|
|
267
|
+
// "tailwindcss/no-unnecessary-arbitrary-value": WARN,
|
|
268
|
+
// "tailwindcss/no-arbitrary-value": OFF
|
|
269
|
+
// }
|
|
270
|
+
// }
|
|
271
|
+
// : null,
|
|
262
272
|
hasNext ? {
|
|
263
273
|
name: "eslint/config/next",
|
|
264
274
|
files: ["**/*.ts?(x)", "**/*.js?(x)"],
|
|
@@ -266,27 +276,7 @@ var config = [
|
|
|
266
276
|
"@next/next": nextPlugin__default.default
|
|
267
277
|
},
|
|
268
278
|
rules: {
|
|
269
|
-
|
|
270
|
-
"@next/next/no-assign-module-variable": ERROR,
|
|
271
|
-
"@next/next/no-document-import-in-page": ERROR,
|
|
272
|
-
"@next/next/no-duplicate-head": ERROR,
|
|
273
|
-
"@next/next/no-head-import-in-document": ERROR,
|
|
274
|
-
"@next/next/no-script-component-in-head": ERROR,
|
|
275
|
-
"@next/next/google-font-display": WARN,
|
|
276
|
-
"@next/next/google-font-preconnect": WARN,
|
|
277
|
-
"@next/next/next-script-for-ga": WARN,
|
|
278
|
-
"@next/next/no-async-client-component": WARN,
|
|
279
|
-
"@next/next/no-before-interactive-script-outside-document": WARN,
|
|
280
|
-
"@next/next/no-css-tags": WARN,
|
|
281
|
-
"@next/next/no-head-element": WARN,
|
|
282
|
-
"@next/next/no-html-link-for-pages": WARN,
|
|
283
|
-
"@next/next/no-img-element": WARN,
|
|
284
|
-
"@next/next/no-page-custom-font": WARN,
|
|
285
|
-
"@next/next/no-styled-jsx-in-document": WARN,
|
|
286
|
-
"@next/next/no-sync-scripts": WARN,
|
|
287
|
-
"@next/next/no-title-in-document-head": WARN,
|
|
288
|
-
"@next/next/no-typos": WARN,
|
|
289
|
-
"@next/next/no-unwanted-polyfillio": WARN
|
|
279
|
+
...nextPlugin__default.default.configs.recommended.rules
|
|
290
280
|
}
|
|
291
281
|
} : null,
|
|
292
282
|
hasTypeScript ? {
|
|
@@ -322,7 +312,7 @@ var config = [
|
|
|
322
312
|
"@typescript-eslint/no-unsafe-declaration-merging": ERROR,
|
|
323
313
|
"@typescript-eslint/no-unsafe-function-type": ERROR,
|
|
324
314
|
"@typescript-eslint/no-wrapper-object-types": ERROR,
|
|
325
|
-
"@typescript-eslint/prefer-as-const":
|
|
315
|
+
"@typescript-eslint/prefer-as-const": ERROR,
|
|
326
316
|
"@typescript-eslint/prefer-namespace-keyword": ERROR,
|
|
327
317
|
"@typescript-eslint/triple-slash-reference": ERROR,
|
|
328
318
|
"@typescript-eslint/no-empty-object-type": WARN,
|
|
@@ -463,7 +453,7 @@ var config = [
|
|
|
463
453
|
"storybook/no-redundant-story-name": WARN,
|
|
464
454
|
"storybook/prefer-pascal-case": WARN,
|
|
465
455
|
"storybook/hierarchy-separator": WARN,
|
|
466
|
-
"react-hooks/rules-of-hooks": OFF,
|
|
456
|
+
...hasReact ? { "react-hooks/rules-of-hooks": OFF } : {},
|
|
467
457
|
"import/no-anonymous-default-export": OFF
|
|
468
458
|
}
|
|
469
459
|
} : null,
|
|
@@ -474,7 +464,7 @@ var config = [
|
|
|
474
464
|
"storybook/no-uninstalled-addons": ERROR
|
|
475
465
|
}
|
|
476
466
|
} : null
|
|
477
|
-
].filter(
|
|
467
|
+
].filter((c) => c !== null);
|
|
478
468
|
var index_default = config;
|
|
479
469
|
|
|
480
470
|
module.exports = index_default;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Shared types for ESLint Core.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The human readable severity level used in a configuration.
|
|
9
|
+
*/
|
|
10
|
+
type SeverityName = "off" | "warn" | "error";
|
|
11
|
+
/**
|
|
12
|
+
* The numeric severity level for a rule.
|
|
13
|
+
*
|
|
14
|
+
* - `0` means off.
|
|
15
|
+
* - `1` means warn.
|
|
16
|
+
* - `2` means error.
|
|
17
|
+
*/
|
|
18
|
+
type SeverityLevel = 0 | 1 | 2;
|
|
19
|
+
/**
|
|
20
|
+
* The severity of a rule in a configuration.
|
|
21
|
+
*/
|
|
22
|
+
type Severity = SeverityName | SeverityLevel;
|
|
23
|
+
/**
|
|
24
|
+
* The configuration for a rule.
|
|
25
|
+
*/
|
|
26
|
+
type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
|
27
|
+
/**
|
|
28
|
+
* A collection of rules and their configurations.
|
|
29
|
+
*/
|
|
30
|
+
interface RulesConfig {
|
|
31
|
+
[key: string]: RuleConfig;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const config: Linter.Config<RulesConfig>[];
|
|
35
|
+
|
|
36
|
+
export { config as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Shared types for ESLint Core.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The human readable severity level used in a configuration.
|
|
9
|
+
*/
|
|
10
|
+
type SeverityName = "off" | "warn" | "error";
|
|
11
|
+
/**
|
|
12
|
+
* The numeric severity level for a rule.
|
|
13
|
+
*
|
|
14
|
+
* - `0` means off.
|
|
15
|
+
* - `1` means warn.
|
|
16
|
+
* - `2` means error.
|
|
17
|
+
*/
|
|
18
|
+
type SeverityLevel = 0 | 1 | 2;
|
|
19
|
+
/**
|
|
20
|
+
* The severity of a rule in a configuration.
|
|
21
|
+
*/
|
|
22
|
+
type Severity = SeverityName | SeverityLevel;
|
|
23
|
+
/**
|
|
24
|
+
* The configuration for a rule.
|
|
25
|
+
*/
|
|
26
|
+
type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
|
27
|
+
/**
|
|
28
|
+
* A collection of rules and their configurations.
|
|
29
|
+
*/
|
|
30
|
+
interface RulesConfig {
|
|
31
|
+
[key: string]: RuleConfig;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare const config: Linter.Config<RulesConfig>[];
|
|
35
|
+
|
|
36
|
+
export { config as default };
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import { readFileSync, existsSync } from 'fs';
|
|
2
2
|
import { join, resolve } from 'path';
|
|
3
|
-
import
|
|
3
|
+
import importPlugin from 'eslint-plugin-import';
|
|
4
4
|
import jestDomPlugin from 'eslint-plugin-jest-dom';
|
|
5
5
|
import playwrightPlugin from 'eslint-plugin-playwright';
|
|
6
6
|
import reactPlugin from 'eslint-plugin-react';
|
|
7
|
-
import
|
|
7
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
8
8
|
import storybookPlugin from 'eslint-plugin-storybook';
|
|
9
|
-
import 'eslint-plugin-tailwindcss';
|
|
10
9
|
import testingLibraryPlugin from 'eslint-plugin-testing-library';
|
|
11
10
|
import globals from 'globals';
|
|
12
11
|
import tsEslint from 'typescript-eslint';
|
|
13
12
|
import nextPlugin from '@next/eslint-plugin-next';
|
|
14
13
|
import vitestPlugin from '@vitest/eslint-plugin';
|
|
15
14
|
|
|
16
|
-
// src/index.
|
|
15
|
+
// src/index.ts
|
|
17
16
|
var logger = console;
|
|
18
17
|
function isPackageInstalled(packageName) {
|
|
19
18
|
const currentDir = process.cwd();
|
|
20
19
|
const packageJsonPath = findPackageJson(currentDir);
|
|
20
|
+
if (!packageJsonPath) {
|
|
21
|
+
logger.error("Could not find package.json in", currentDir, "or any parent directory.");
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
21
24
|
try {
|
|
22
25
|
const packageJson = readFileSync(packageJsonPath, "utf-8");
|
|
23
26
|
const parsedPackageJson = JSON.parse(packageJson);
|
|
24
27
|
const dependencies = parsedPackageJson.dependencies || {};
|
|
25
28
|
const devDependencies = parsedPackageJson.devDependencies || {};
|
|
26
|
-
return
|
|
29
|
+
return packageName in dependencies || packageName in devDependencies;
|
|
27
30
|
} catch (error) {
|
|
28
31
|
logger.error("Error reading package.json file:", error);
|
|
29
32
|
process.exit(1);
|
|
@@ -224,7 +227,32 @@ var config = [
|
|
|
224
227
|
"react-hooks/exhaustive-deps": WARN
|
|
225
228
|
}
|
|
226
229
|
} : null,
|
|
227
|
-
|
|
230
|
+
// TODO add when support for tailwindcss v4 will be added
|
|
231
|
+
// hasTailwindcss
|
|
232
|
+
// ? {
|
|
233
|
+
// name: "eslint/config/tailwindcss",
|
|
234
|
+
// plugins: {
|
|
235
|
+
// tailwindcss: tailwindcssPlugin
|
|
236
|
+
// },
|
|
237
|
+
// languageOptions: {
|
|
238
|
+
// parserOptions: {
|
|
239
|
+
// ecmaFeatures: {
|
|
240
|
+
// jsx: true
|
|
241
|
+
// }
|
|
242
|
+
// }
|
|
243
|
+
// },
|
|
244
|
+
// rules: {
|
|
245
|
+
// "tailwindcss/no-contradicting-classname": ERROR,
|
|
246
|
+
// "tailwindcss/classnames-order": WARN,
|
|
247
|
+
// "tailwindcss/enforces-negative-arbitrary-values": WARN,
|
|
248
|
+
// "tailwindcss/enforces-shorthand": WARN,
|
|
249
|
+
// "tailwindcss/migration-from-tailwind-2": WARN,
|
|
250
|
+
// "tailwindcss/no-custom-classname": WARN,
|
|
251
|
+
// "tailwindcss/no-unnecessary-arbitrary-value": WARN,
|
|
252
|
+
// "tailwindcss/no-arbitrary-value": OFF
|
|
253
|
+
// }
|
|
254
|
+
// }
|
|
255
|
+
// : null,
|
|
228
256
|
hasNext ? {
|
|
229
257
|
name: "eslint/config/next",
|
|
230
258
|
files: ["**/*.ts?(x)", "**/*.js?(x)"],
|
|
@@ -232,27 +260,7 @@ var config = [
|
|
|
232
260
|
"@next/next": nextPlugin
|
|
233
261
|
},
|
|
234
262
|
rules: {
|
|
235
|
-
|
|
236
|
-
"@next/next/no-assign-module-variable": ERROR,
|
|
237
|
-
"@next/next/no-document-import-in-page": ERROR,
|
|
238
|
-
"@next/next/no-duplicate-head": ERROR,
|
|
239
|
-
"@next/next/no-head-import-in-document": ERROR,
|
|
240
|
-
"@next/next/no-script-component-in-head": ERROR,
|
|
241
|
-
"@next/next/google-font-display": WARN,
|
|
242
|
-
"@next/next/google-font-preconnect": WARN,
|
|
243
|
-
"@next/next/next-script-for-ga": WARN,
|
|
244
|
-
"@next/next/no-async-client-component": WARN,
|
|
245
|
-
"@next/next/no-before-interactive-script-outside-document": WARN,
|
|
246
|
-
"@next/next/no-css-tags": WARN,
|
|
247
|
-
"@next/next/no-head-element": WARN,
|
|
248
|
-
"@next/next/no-html-link-for-pages": WARN,
|
|
249
|
-
"@next/next/no-img-element": WARN,
|
|
250
|
-
"@next/next/no-page-custom-font": WARN,
|
|
251
|
-
"@next/next/no-styled-jsx-in-document": WARN,
|
|
252
|
-
"@next/next/no-sync-scripts": WARN,
|
|
253
|
-
"@next/next/no-title-in-document-head": WARN,
|
|
254
|
-
"@next/next/no-typos": WARN,
|
|
255
|
-
"@next/next/no-unwanted-polyfillio": WARN
|
|
263
|
+
...nextPlugin.configs.recommended.rules
|
|
256
264
|
}
|
|
257
265
|
} : null,
|
|
258
266
|
hasTypeScript ? {
|
|
@@ -288,7 +296,7 @@ var config = [
|
|
|
288
296
|
"@typescript-eslint/no-unsafe-declaration-merging": ERROR,
|
|
289
297
|
"@typescript-eslint/no-unsafe-function-type": ERROR,
|
|
290
298
|
"@typescript-eslint/no-wrapper-object-types": ERROR,
|
|
291
|
-
"@typescript-eslint/prefer-as-const":
|
|
299
|
+
"@typescript-eslint/prefer-as-const": ERROR,
|
|
292
300
|
"@typescript-eslint/prefer-namespace-keyword": ERROR,
|
|
293
301
|
"@typescript-eslint/triple-slash-reference": ERROR,
|
|
294
302
|
"@typescript-eslint/no-empty-object-type": WARN,
|
|
@@ -429,7 +437,7 @@ var config = [
|
|
|
429
437
|
"storybook/no-redundant-story-name": WARN,
|
|
430
438
|
"storybook/prefer-pascal-case": WARN,
|
|
431
439
|
"storybook/hierarchy-separator": WARN,
|
|
432
|
-
"react-hooks/rules-of-hooks": OFF,
|
|
440
|
+
...hasReact ? { "react-hooks/rules-of-hooks": OFF } : {},
|
|
433
441
|
"import/no-anonymous-default-export": OFF
|
|
434
442
|
}
|
|
435
443
|
} : null,
|
|
@@ -440,7 +448,7 @@ var config = [
|
|
|
440
448
|
"storybook/no-uninstalled-addons": ERROR
|
|
441
449
|
}
|
|
442
450
|
} : null
|
|
443
|
-
].filter(
|
|
451
|
+
].filter((c) => c !== null);
|
|
444
452
|
var index_default = config;
|
|
445
453
|
|
|
446
454
|
export { index_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@szum-tech/eslint-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "ESLint configuration for TypeScript projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"type": "module",
|
|
23
23
|
"main": "./dist/index.cjs",
|
|
24
24
|
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
25
26
|
"files": [
|
|
26
27
|
"dist/**"
|
|
27
28
|
],
|
|
@@ -32,34 +33,36 @@
|
|
|
32
33
|
"lint:fix": "eslint . --fix",
|
|
33
34
|
"lint:inspect": "npx @eslint/config-inspector@latest",
|
|
34
35
|
"prettier:check": "prettier --check .",
|
|
35
|
-
"prettier:write": "prettier --write ."
|
|
36
|
+
"prettier:write": "prettier --write .",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
36
38
|
},
|
|
37
39
|
"dependencies": {
|
|
38
|
-
"@next/eslint-plugin-next": "^16.
|
|
39
|
-
"@vitest/eslint-plugin": "^1.6.
|
|
40
|
+
"@next/eslint-plugin-next": "^16.1.6",
|
|
41
|
+
"@vitest/eslint-plugin": "^1.6.7",
|
|
40
42
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
41
43
|
"eslint-plugin-import": "^2.32.0",
|
|
42
44
|
"eslint-plugin-jest-dom": "^5.4.0",
|
|
43
|
-
"eslint-plugin-playwright": "^2.
|
|
45
|
+
"eslint-plugin-playwright": "^2.5.1",
|
|
44
46
|
"eslint-plugin-react": "^7.37.5",
|
|
45
47
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
46
|
-
"eslint-plugin-storybook": "^10.
|
|
48
|
+
"eslint-plugin-storybook": "^10.2.8",
|
|
47
49
|
"eslint-plugin-tailwindcss": "^4.0.0-beta.0",
|
|
48
50
|
"eslint-plugin-testing-library": "^7.13.5",
|
|
49
|
-
"globals": "^17.
|
|
50
|
-
"typescript-eslint": "^8.
|
|
51
|
+
"globals": "^17.3.0",
|
|
52
|
+
"typescript-eslint": "^8.55.0"
|
|
51
53
|
},
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@szum-tech/prettier-config": "^1.6.2",
|
|
54
|
-
"@szum-tech/semantic-release-config": "^2.3.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
56
|
+
"@szum-tech/semantic-release-config": "^2.3.7",
|
|
57
|
+
"@types/node": "^22.15.0",
|
|
58
|
+
"eslint": "^9.39.2",
|
|
59
|
+
"prettier": "^3.8.1",
|
|
60
|
+
"semantic-release": "^25.0.3",
|
|
58
61
|
"tsup": "^8.5.0",
|
|
59
62
|
"typescript": "^5.8.3"
|
|
60
63
|
},
|
|
61
64
|
"peerDependencies": {
|
|
62
|
-
"eslint": ">=9.
|
|
65
|
+
"eslint": ">=9.0.0"
|
|
63
66
|
},
|
|
64
67
|
"publishConfig": {
|
|
65
68
|
"access": "public"
|