@szum-tech/eslint-config 2.0.0 → 2.1.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.js ADDED
@@ -0,0 +1,396 @@
1
+ import importPlugin from 'eslint-plugin-import';
2
+ import jestDomPlugin from 'eslint-plugin-jest-dom';
3
+ import playwrightPlugin from 'eslint-plugin-playwright';
4
+ import reactPlugin from 'eslint-plugin-react';
5
+ import reactHooksPlugin from 'eslint-plugin-react-hooks';
6
+ import storybookPlugin from 'eslint-plugin-storybook';
7
+ import tailwindcssPlugin from 'eslint-plugin-tailwindcss';
8
+ import testingLibraryPlugin from 'eslint-plugin-testing-library';
9
+ import globals from 'globals';
10
+ import tsEslint from 'typescript-eslint';
11
+ import nextPlugin from '@next/eslint-plugin-next';
12
+ import vitestPlugin from '@vitest/eslint-plugin';
13
+
14
+ // src/index.js
15
+ var ERROR = "error";
16
+ var WARN = "warn";
17
+ var OFF = "off";
18
+ var has = (pkg) => {
19
+ try {
20
+ import.meta.resolve(pkg, import.meta.url);
21
+ return true;
22
+ } catch {
23
+ return false;
24
+ }
25
+ };
26
+ var hasTypeScript = has("typescript");
27
+ var hasTailwindcss = has("tailwindcss");
28
+ var hasReact = has("react");
29
+ var hasNext = has("next");
30
+ var hasTestingLibrary = has("@testing-library/dom");
31
+ var hasJestDom = has("@testing-library/jest-dom");
32
+ var hasVitest = has("vitest");
33
+ var hasPlaywright = has("@playwright/test");
34
+ var hasStorybook = has("storybook");
35
+ var vitestFiles = ["**/__tests__/**/*", "**/*.test.*"];
36
+ var testFiles = ["**/tests/**", ...vitestFiles];
37
+ var playwrightFiles = ["**/e2e/**", "**/*.e2e.*"];
38
+ var config = [
39
+ {
40
+ name: "eslint/ignores",
41
+ ignores: [
42
+ "**/.cache/**",
43
+ "**/node_modules/**",
44
+ "**/build/**",
45
+ "**/public/build/**",
46
+ "**/playwright-report/**",
47
+ "**/server-build/**",
48
+ "**/dist/**",
49
+ "**/.next/**"
50
+ ]
51
+ },
52
+ {
53
+ name: "eslint/config/base&import",
54
+ plugins: {
55
+ import: importPlugin
56
+ },
57
+ languageOptions: {
58
+ globals: {
59
+ ...globals.browser,
60
+ ...globals.node
61
+ },
62
+ parserOptions: {
63
+ warnOnUnsupportedTypeScriptVersion: false
64
+ }
65
+ },
66
+ rules: {
67
+ "no-unexpected-multiline": ERROR,
68
+ "no-warning-comments": [ERROR, { terms: ["FIXME"], location: "anywhere" }],
69
+ "no-console": WARN,
70
+ "no-unused-vars": [
71
+ WARN,
72
+ {
73
+ args: "after-used",
74
+ argsIgnorePattern: "^_",
75
+ ignoreRestSiblings: true,
76
+ varsIgnorePattern: "^ignored"
77
+ }
78
+ ],
79
+ // analysis/correctness
80
+ "import/default": ERROR,
81
+ "import/namespace": ERROR,
82
+ "import/export": ERROR,
83
+ "import/no-unresolved": OFF,
84
+ "import/named": OFF,
85
+ // red flags (thus, warnings)
86
+ "import/consistent-type-specifier-style": [WARN, "prefer-inline"],
87
+ "import/no-named-as-default": WARN,
88
+ "import/no-named-as-default-member": WARN,
89
+ "import/no-duplicates": [WARN, { "prefer-inline": true }],
90
+ "import/order": [
91
+ WARN,
92
+ {
93
+ groups: ["builtin", "external", "internal", "parent", "sibling", "index"],
94
+ pathGroups: [
95
+ {
96
+ pattern: "react",
97
+ group: "external",
98
+ position: "before"
99
+ },
100
+ { pattern: "*/**", group: "internal" }
101
+ ],
102
+ pathGroupsExcludedImportTypes: ["react"],
103
+ "newlines-between": "always",
104
+ alphabetize: {
105
+ order: "asc",
106
+ caseInsensitive: true
107
+ }
108
+ }
109
+ ]
110
+ }
111
+ },
112
+ hasReact ? {
113
+ name: "eslint/config/react&react-hooks",
114
+ files: ["**/*.tsx", "**/*.jsx"],
115
+ plugins: {
116
+ react: reactPlugin,
117
+ "react-hooks": reactHooksPlugin
118
+ },
119
+ languageOptions: {
120
+ parser: tsEslint.parser,
121
+ parserOptions: {
122
+ jsx: true
123
+ }
124
+ },
125
+ settings: {
126
+ react: {
127
+ version: "detect"
128
+ }
129
+ },
130
+ rules: {
131
+ "react/display-name": ERROR,
132
+ "react/jsx-no-comment-textnodes": ERROR,
133
+ "react/jsx-no-duplicate-props": ERROR,
134
+ "react/jsx-no-target-blank": ERROR,
135
+ "react/jsx-no-undef": ERROR,
136
+ "react/jsx-uses-react": ERROR,
137
+ "react/jsx-uses-vars": ERROR,
138
+ "react/no-children-prop": ERROR,
139
+ "react/no-danger-with-children": ERROR,
140
+ "react/no-deprecated": ERROR,
141
+ "react/no-direct-mutation-state": ERROR,
142
+ "react/no-find-dom-node": ERROR,
143
+ "react/no-is-mounted": ERROR,
144
+ "react/no-render-return-value": ERROR,
145
+ "react/no-unescaped-entities": ERROR,
146
+ "react/no-unknown-property": ERROR,
147
+ "react/require-render-return": ERROR,
148
+ "react/jsx-key": WARN,
149
+ "react/react-in-jsx-scope": OFF,
150
+ "react/no-unsafe": OFF,
151
+ "react-hooks/rules-of-hooks": ERROR,
152
+ "react-hooks/exhaustive-deps": WARN
153
+ }
154
+ } : null,
155
+ hasTailwindcss ? {
156
+ name: "eslint/config/tailwindcss",
157
+ plugins: {
158
+ tailwindcss: tailwindcssPlugin
159
+ },
160
+ languageOptions: {
161
+ parserOptions: {
162
+ ecmaFeatures: {
163
+ jsx: true
164
+ }
165
+ }
166
+ },
167
+ rules: {
168
+ "tailwindcss/no-contradicting-classname": ERROR,
169
+ "tailwindcss/classnames-order": WARN,
170
+ "tailwindcss/enforces-negative-arbitrary-values": WARN,
171
+ "tailwindcss/enforces-shorthand": WARN,
172
+ "tailwindcss/migration-from-tailwind-2": WARN,
173
+ "tailwindcss/no-custom-classname": WARN,
174
+ "tailwindcss/no-unnecessary-arbitrary-value": WARN,
175
+ "tailwindcss/no-arbitrary-value": OFF
176
+ }
177
+ } : null,
178
+ hasNext ? {
179
+ name: "eslint/config/next",
180
+ files: ["**/*.ts?(x)", "**/*.js?(x)"],
181
+ plugins: {
182
+ "@next/next": nextPlugin
183
+ },
184
+ rules: {
185
+ "@next/next/inline-script-id": ERROR,
186
+ "@next/next/no-assign-module-variable": ERROR,
187
+ "@next/next/no-document-import-in-page": ERROR,
188
+ "@next/next/no-duplicate-head": ERROR,
189
+ "@next/next/no-head-import-in-document": ERROR,
190
+ "@next/next/no-script-component-in-head": ERROR,
191
+ "@next/next/google-font-display": WARN,
192
+ "@next/next/google-font-preconnect": WARN,
193
+ "@next/next/next-script-for-ga": WARN,
194
+ "@next/next/no-async-client-component": WARN,
195
+ "@next/next/no-before-interactive-script-outside-document": WARN,
196
+ "@next/next/no-css-tags": WARN,
197
+ "@next/next/no-head-element": WARN,
198
+ "@next/next/no-html-link-for-pages": WARN,
199
+ "@next/next/no-img-element": WARN,
200
+ "@next/next/no-page-custom-font": WARN,
201
+ "@next/next/no-styled-jsx-in-document": WARN,
202
+ "@next/next/no-sync-scripts": WARN,
203
+ "@next/next/no-title-in-document-head": WARN,
204
+ "@next/next/no-typos": WARN,
205
+ "@next/next/no-unwanted-polyfillio": WARN
206
+ }
207
+ } : null,
208
+ hasTypeScript ? {
209
+ name: "eslint/config/typescript",
210
+ files: ["**/*.ts?(x)"],
211
+ languageOptions: {
212
+ parser: tsEslint.parser,
213
+ parserOptions: {
214
+ projectService: true
215
+ },
216
+ sourceType: "module"
217
+ },
218
+ plugins: {
219
+ "@typescript-eslint": tsEslint.plugin
220
+ },
221
+ rules: {
222
+ "no-unused-expressions": OFF,
223
+ "no-array-constructor": OFF,
224
+ "no-unused-vars": OFF,
225
+ "@typescript-eslint/no-misused-promises": [ERROR, { checksVoidReturn: false }],
226
+ "@typescript-eslint/no-floating-promises": ERROR,
227
+ "@typescript-eslint/ban-ts-comment": ERROR,
228
+ "@typescript-eslint/no-array-constructor": ERROR,
229
+ "@typescript-eslint/no-duplicate-enum-values": ERROR,
230
+ "@typescript-eslint/no-explicit-any": ERROR,
231
+ "@typescript-eslint/no-extra-non-null-assertion": ERROR,
232
+ "@typescript-eslint/no-misused-new": ERROR,
233
+ "@typescript-eslint/no-namespace": ERROR,
234
+ "@typescript-eslint/no-non-null-asserted-optional-chain": ERROR,
235
+ "@typescript-eslint/no-require-imports": ERROR,
236
+ "@typescript-eslint/no-this-alias": ERROR,
237
+ "@typescript-eslint/no-unnecessary-type-constraint": ERROR,
238
+ "@typescript-eslint/no-unsafe-declaration-merging": ERROR,
239
+ "@typescript-eslint/no-unsafe-function-type": ERROR,
240
+ "@typescript-eslint/no-wrapper-object-types": ERROR,
241
+ "@typescript-eslint/prefer-as-const": "error",
242
+ "@typescript-eslint/prefer-namespace-keyword": ERROR,
243
+ "@typescript-eslint/triple-slash-reference": ERROR,
244
+ "@typescript-eslint/no-empty-object-type": WARN,
245
+ "@typescript-eslint/no-unused-vars": [
246
+ WARN,
247
+ {
248
+ args: "all",
249
+ argsIgnorePattern: "^_",
250
+ caughtErrors: "all",
251
+ caughtErrorsIgnorePattern: "^_",
252
+ destructuredArrayIgnorePattern: "^_",
253
+ varsIgnorePattern: "^_",
254
+ ignoreRestSiblings: true
255
+ }
256
+ ],
257
+ "@typescript-eslint/consistent-type-imports": [
258
+ WARN,
259
+ {
260
+ prefer: "type-imports",
261
+ disallowTypeAnnotations: true,
262
+ fixStyle: "inline-type-imports"
263
+ }
264
+ ]
265
+ }
266
+ } : null,
267
+ hasTestingLibrary ? {
268
+ name: "eslint/config/testing-library",
269
+ files: testFiles,
270
+ ignores: playwrightFiles,
271
+ plugins: {
272
+ "testing-library": testingLibraryPlugin
273
+ },
274
+ rules: {
275
+ "testing-library/no-unnecessary-act": [ERROR, { isStrict: false }],
276
+ "testing-library/no-wait-for-side-effects": ERROR,
277
+ "testing-library/prefer-find-by": ERROR
278
+ }
279
+ } : null,
280
+ hasJestDom ? {
281
+ name: "eslint/config/jest-dom",
282
+ files: testFiles,
283
+ ignores: playwrightFiles,
284
+ plugins: {
285
+ "jest-dom": jestDomPlugin
286
+ },
287
+ rules: {
288
+ "jest-dom/prefer-checked": ERROR,
289
+ "jest-dom/prefer-enabled-disabled": ERROR,
290
+ "jest-dom/prefer-focus": ERROR,
291
+ "jest-dom/prefer-empty": ERROR,
292
+ "jest-dom/prefer-to-have-value": ERROR,
293
+ "jest-dom/prefer-to-have-text-content": ERROR,
294
+ "jest-dom/prefer-required": ERROR
295
+ }
296
+ } : null,
297
+ hasVitest ? {
298
+ name: "eslint/config/vitest",
299
+ files: testFiles,
300
+ ignores: playwrightFiles,
301
+ plugins: {
302
+ vitest: vitestPlugin
303
+ },
304
+ settings: {
305
+ vitest: {
306
+ typecheck: hasTypeScript
307
+ }
308
+ },
309
+ languageOptions: {
310
+ globals: {
311
+ ...vitestPlugin.environments.env.globals
312
+ }
313
+ },
314
+ rules: {
315
+ "vitest/expect-expect": ERROR,
316
+ "vitest/no-identical-title": ERROR,
317
+ "vitest/no-commented-out-tests": ERROR,
318
+ "vitest/valid-title": ERROR,
319
+ "vitest/valid-expect": ERROR,
320
+ "vitest/valid-describe-callback": ERROR,
321
+ "vitest/require-local-test-context-for-concurrent-snapshots": ERROR,
322
+ "vitest/no-import-node-test": ERROR,
323
+ "vitest/no-focused-tests": [WARN, { fixable: false }]
324
+ }
325
+ } : null,
326
+ hasPlaywright ? {
327
+ name: "eslint/config/playwright",
328
+ files: playwrightFiles,
329
+ plugins: {
330
+ playwright: playwrightPlugin
331
+ },
332
+ languageOptions: {
333
+ globals: globals["shared-node-browser"]
334
+ },
335
+ rules: {
336
+ "no-empty-pattern": OFF,
337
+ "playwright/missing-playwright-await": ERROR,
338
+ "playwright/no-focused-test": ERROR,
339
+ "playwright/no-networkidle": ERROR,
340
+ "playwright/no-unsafe-references": ERROR,
341
+ "playwright/valid-describe-callback": ERROR,
342
+ "playwright/valid-expect": ERROR,
343
+ "playwright/valid-expect-in-promise": ERROR,
344
+ "playwright/valid-title": ERROR,
345
+ "playwright/prefer-web-first-assertions": ERROR,
346
+ "playwright/no-standalone-expect": ERROR,
347
+ "playwright/expect-expect": WARN,
348
+ "playwright/max-nested-describe": WARN,
349
+ "playwright/no-conditional-expect": WARN,
350
+ "playwright/no-conditional-in-test": WARN,
351
+ "playwright/no-element-handle": WARN,
352
+ "playwright/no-eval": WARN,
353
+ "playwright/no-force-option": WARN,
354
+ "playwright/no-nested-step": WARN,
355
+ "playwright/no-page-pause": WARN,
356
+ "playwright/no-skipped-test": WARN,
357
+ "playwright/no-useless-await": WARN,
358
+ "playwright/no-useless-not": WARN,
359
+ "playwright/no-wait-for-selector": WARN,
360
+ "playwright/no-wait-for-timeout": WARN
361
+ }
362
+ } : null,
363
+ hasStorybook ? {
364
+ name: "eslint/config/storybook",
365
+ plugins: {
366
+ storybook: storybookPlugin
367
+ }
368
+ } : null,
369
+ hasStorybook ? {
370
+ name: "eslint/config/storybook/stories",
371
+ files: ["**/*.stories.@(ts|tsx|js|jsx|mjs|cjs)", "**/*.story.@(ts|tsx|js|jsx|mjs|cjs)"],
372
+ rules: {
373
+ "storybook/await-interactions": ERROR,
374
+ "storybook/context-in-play-function": ERROR,
375
+ "storybook/default-exports": ERROR,
376
+ "storybook/story-exports": ERROR,
377
+ "storybook/use-storybook-expect": ERROR,
378
+ "storybook/use-storybook-testing-library": ERROR,
379
+ "storybook/no-redundant-story-name": WARN,
380
+ "storybook/prefer-pascal-case": WARN,
381
+ "storybook/hierarchy-separator": WARN,
382
+ "react-hooks/rules-of-hooks": OFF,
383
+ "import/no-anonymous-default-export": OFF
384
+ }
385
+ } : null,
386
+ hasStorybook ? {
387
+ name: "eslint/config/storybook/main",
388
+ files: [".storybook/main.@(js|cjs|mjs|ts|tsx)"],
389
+ rules: {
390
+ "storybook/no-uninstalled-addons": ERROR
391
+ }
392
+ } : null
393
+ ].filter(Boolean);
394
+ var index_default = config;
395
+
396
+ 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.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "ESLint configuration for TypeScript projects",
5
5
  "keywords": [
6
6
  "eslint",
@@ -20,58 +20,56 @@
20
20
  "license": "MIT",
21
21
  "author": "Jan Szewczyk (Szum-Tech)",
22
22
  "type": "module",
23
- "main": "index.js",
24
- "module": "index.js",
23
+ "main": "./dist/index.cjs",
24
+ "module": ".dist/index.js",
25
25
  "files": [
26
- "index.js"
26
+ "dist/**"
27
27
  ],
28
28
  "scripts": {
29
+ "build": "tsup",
29
30
  "lint": "eslint .",
30
- "lint:ci": "eslint . --max-warnings=0",
31
+ "lint:ci": "eslint . -o eslint-results.sarif -f @microsoft/eslint-formatter-sarif",
31
32
  "lint:fix": "eslint . --fix",
32
33
  "lint:inspect": "npx @eslint/config-inspector@latest",
33
34
  "prettier:check": "prettier --check .",
34
- "prettier:write": "prettier --write .",
35
- "semantic-release": "semantic-release",
36
- "test": "node test/test.test.js"
35
+ "prettier:write": "prettier --write ."
37
36
  },
38
37
  "dependencies": {
39
- "@next/eslint-plugin-next": "^15.0.3",
40
- "@vitest/eslint-plugin": "^1.1.10",
41
- "eslint-config-prettier": "^9.1.0",
38
+ "@next/eslint-plugin-next": "^15.1.2",
39
+ "@vitest/eslint-plugin": "^1.1.20",
42
40
  "eslint-plugin-import": "^2.31.0",
43
41
  "eslint-plugin-jest-dom": "^5.4.0",
44
42
  "eslint-plugin-playwright": "^2.0.1",
45
- "eslint-plugin-react": "^7.37.1",
46
- "eslint-plugin-react-hooks": "^5.0.0",
43
+ "eslint-plugin-react": "^7.37.3",
44
+ "eslint-plugin-react-hooks": "^5.1.0",
47
45
  "eslint-plugin-storybook": "^0.11.0",
48
46
  "eslint-plugin-tailwindcss": "^3.17.5",
49
- "eslint-plugin-testing-library": "^6.5.0",
50
- "globals": "^15.12.0",
51
- "typescript-eslint": "^8.15.0"
47
+ "eslint-plugin-testing-library": "^7.1.1",
48
+ "globals": "^15.14.0",
49
+ "typescript-eslint": "^8.18.2"
52
50
  },
53
51
  "devDependencies": {
54
- "@szum-tech/prettier-config": "^1.3.5",
55
- "@szum-tech/semantic-release-preset": "^1.5.7",
56
- "eslint": "^9.15.0",
57
- "prettier": "^3.3.3",
58
- "semantic-release": "^24.2.0"
52
+ "@microsoft/eslint-formatter-sarif": "^3.1.0",
53
+ "@szum-tech/prettier-config": "^1.4.5",
54
+ "@szum-tech/semantic-release-config": "^2.2.1",
55
+ "eslint": "^9.17.0",
56
+ "prettier": "^3.4.2",
57
+ "semantic-release": "^24.2.0",
58
+ "tsup": "^8.3.5",
59
+ "typescript": "^5.7.2"
59
60
  },
60
61
  "peerDependencies": {
61
- "@next/eslint-plugin-next": "^15.0.3",
62
- "@vitest/eslint-plugin": "^1.1.10",
63
- "eslint": "^9.15.0",
64
- "eslint-config-prettier": "^9.1.0",
62
+ "eslint": "^9.17.0",
65
63
  "eslint-plugin-import": "^2.31.0",
66
64
  "eslint-plugin-jest-dom": "^5.4.0",
67
65
  "eslint-plugin-playwright": "^2.0.1",
68
- "eslint-plugin-react": "^7.37.1",
69
- "eslint-plugin-react-hooks": "^5.0.0",
66
+ "eslint-plugin-react": "^7.37.3",
67
+ "eslint-plugin-react-hooks": "^5.1.0",
70
68
  "eslint-plugin-storybook": "^0.11.0",
71
69
  "eslint-plugin-tailwindcss": "^3.17.5",
72
- "eslint-plugin-testing-library": "^6.5.0",
73
- "globals": "^15.12.0",
74
- "typescript-eslint": "^8.15.0"
70
+ "eslint-plugin-testing-library": "^7.1.1",
71
+ "globals": "^15.14.0",
72
+ "typescript-eslint": "^8.18.2"
75
73
  },
76
74
  "publishConfig": {
77
75
  "access": "public"