@szum-tech/eslint-config 2.1.16 → 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/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 +5 -2
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,7 +33,8 @@
|
|
|
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
40
|
"@next/eslint-plugin-next": "^16.1.6",
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
"devDependencies": {
|
|
53
55
|
"@szum-tech/prettier-config": "^1.6.2",
|
|
54
56
|
"@szum-tech/semantic-release-config": "^2.3.7",
|
|
57
|
+
"@types/node": "^22.15.0",
|
|
55
58
|
"eslint": "^9.39.2",
|
|
56
59
|
"prettier": "^3.8.1",
|
|
57
60
|
"semantic-release": "^25.0.3",
|