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