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