@szum-tech/eslint-config 2.0.1 → 2.1.1

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