|
1 | | -const typescript = require('@typescript-eslint/eslint-plugin'); |
2 | | -const typescriptParser = require('@typescript-eslint/parser'); |
3 | | -const prettier = require('eslint-plugin-prettier'); |
4 | | -const importPlugin = require('eslint-plugin-import'); |
5 | | -const jsdoc = require('eslint-plugin-jsdoc'); |
6 | | -const playwright = require('eslint-plugin-playwright'); |
7 | | -const js = require('@eslint/js'); |
| 1 | +/** |
| 2 | + * ESLint config that extends vasu-playwright-utils shared config. |
| 3 | + * @see https://www.npmjs.com/package/vasu-playwright-utils |
| 4 | + * |
| 5 | + * @example |
| 6 | + * // eslint.config.js (in your project) |
| 7 | + * const playwrightLibConfig = require('vasu-playwright-utils/eslint'); |
| 8 | + * module.exports = [ |
| 9 | + * ...playwrightLibConfig, |
| 10 | + * { rules: { 'playwright/no-focused-test': 'warn' } }, |
| 11 | + * ]; |
| 12 | + */ |
| 13 | +const playwrightLibConfig = require('vasu-playwright-utils/eslint'); |
8 | 14 |
|
9 | 15 | module.exports = [ |
| 16 | + // Project-specific ignores (in addition to lib defaults) |
10 | 17 | { |
11 | 18 | ignores: [ |
12 | | - 'node_modules/**', |
13 | 19 | 'test-results/**', |
14 | 20 | 'playwright-report/**', |
15 | 21 | 'playwright/.cache/**', |
16 | 22 | 'playwright/.auth/**', |
17 | | - '.husky/**', |
18 | 23 | '.env', |
19 | 24 | '.vscode/**', |
20 | 25 | '.idea/**', |
21 | 26 | '.DS_Store', |
22 | 27 | 'allure*/**', |
23 | | - 'dist/**', |
24 | | - 'package-lock.json', |
25 | 28 | '**/*.sh', |
26 | 29 | '**/*.png', |
27 | 30 | '*.md', |
28 | | - '**/*.js', |
29 | 31 | ], |
30 | 32 | }, |
31 | | - // Base ESLint recommended rules |
32 | | - js.configs.recommended, |
33 | | - |
34 | | - // TypeScript configuration |
35 | | - { |
36 | | - files: ['**/*.ts'], |
37 | | - languageOptions: { |
38 | | - parser: typescriptParser, |
39 | | - parserOptions: { project: './tsconfig.json', tsconfigRootDir: __dirname }, |
40 | | - globals: { |
41 | | - // Node.js globals |
42 | | - console: 'readonly', |
43 | | - process: 'readonly', |
44 | | - Buffer: 'readonly', |
45 | | - __dirname: 'readonly', |
46 | | - __filename: 'readonly', |
47 | | - global: 'readonly', |
48 | | - module: 'readonly', |
49 | | - require: 'readonly', |
50 | | - exports: 'readonly', |
51 | | - // Browser globals |
52 | | - window: 'readonly', |
53 | | - document: 'readonly', |
54 | | - navigator: 'readonly', |
55 | | - location: 'readonly', |
56 | | - history: 'readonly', |
57 | | - localStorage: 'readonly', |
58 | | - sessionStorage: 'readonly', |
59 | | - fetch: 'readonly', |
60 | | - XMLHttpRequest: 'readonly', |
61 | | - FormData: 'readonly', |
62 | | - URLSearchParams: 'readonly', |
63 | | - URL: 'readonly', |
64 | | - Event: 'readonly', |
65 | | - EventTarget: 'readonly', |
66 | | - CustomEvent: 'readonly', |
67 | | - setTimeout: 'readonly', |
68 | | - setInterval: 'readonly', |
69 | | - clearTimeout: 'readonly', |
70 | | - clearInterval: 'readonly', |
71 | | - }, |
72 | | - }, |
73 | | - plugins: { |
74 | | - '@typescript-eslint': typescript, |
75 | | - prettier: prettier, |
76 | | - import: importPlugin, |
77 | | - jsdoc: jsdoc, |
78 | | - playwright: playwright, |
79 | | - }, |
80 | | - settings: { 'import/resolver': { typescript: { alwaysTryTypes: true } } }, |
81 | | - rules: { |
82 | | - // Prettier Rules |
83 | | - 'prettier/prettier': 'error', |
84 | | - 'no-trailing-spaces': 'error', |
85 | | - 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }], |
86 | | - 'eol-last': ['error', 'always'], |
87 | | - |
88 | | - // TypeScript Rules - Base |
89 | | - ...typescript.configs.recommended.rules, |
90 | | - ...typescript.configs['eslint-recommended'].overrides[0].rules, |
91 | | - // TypeScript recommended-requiring-type-checking rules (type-aware rules) |
92 | | - ...typescript.configs['recommended-requiring-type-checking'].rules, |
93 | | - '@typescript-eslint/no-unsafe-assignment': 'warn', |
94 | | - '@typescript-eslint/no-unsafe-member-access': 'warn', |
95 | | - '@typescript-eslint/no-unsafe-return': 'warn', |
96 | | - '@typescript-eslint/no-unsafe-call': 'warn', |
97 | | - '@typescript-eslint/no-floating-promises': 'error', |
98 | | - '@typescript-eslint/no-unnecessary-type-assertion': 'error', |
99 | | - '@typescript-eslint/no-explicit-any': 'warn', |
100 | | - '@typescript-eslint/explicit-module-boundary-types': 'off', |
101 | | - |
102 | | - // TypeScript Rules - Additional Strict Rules |
103 | | - '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
104 | | - '@typescript-eslint/no-unused-expressions': 'error', |
105 | | - '@typescript-eslint/no-empty-function': 'warn', |
106 | | - '@typescript-eslint/prefer-nullish-coalescing': 'error', |
107 | | - '@typescript-eslint/prefer-optional-chain': 'error', |
108 | | - '@typescript-eslint/prefer-as-const': 'error', |
109 | | - '@typescript-eslint/no-non-null-assertion': 'warn', |
110 | | - '@typescript-eslint/no-duplicate-enum-values': 'error', |
111 | | - '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: false, ignoreProperties: false }], |
112 | | - |
113 | | - // Import Rules |
114 | | - 'import/no-unresolved': 'error', |
115 | | - 'import/named': 'error', |
116 | | - 'import/default': 'error', |
117 | | - 'import/no-absolute-path': 'error', |
118 | | - 'import/no-self-import': 'error', |
119 | | - // 'import/no-duplicates': 'error', |
120 | | - 'import/first': 'error', |
121 | | - 'import/no-mutable-exports': 'error', |
122 | | - 'sort-imports': ['error', { ignoreDeclarationSort: true }], |
123 | | - |
124 | | - // General Rules |
125 | | - 'require-await': 'off', |
126 | | - '@typescript-eslint/require-await': 'error', |
127 | | - '@typescript-eslint/await-thenable': 'error', |
128 | | - '@typescript-eslint/no-misused-promises': 'error', |
129 | | - complexity: ['warn', { max: 11 }], |
130 | | - 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }], |
131 | | - 'no-debugger': 'error', |
132 | | - 'no-var': 'error', |
133 | | - 'prefer-const': 'error', |
134 | | - 'prefer-template': 'error', |
135 | | - 'object-shorthand': 'error', |
136 | | - // 'no-else-return': ['error', { allowElseIf: false }], |
137 | | - 'no-lonely-if': 'error', |
138 | | - 'no-useless-return': 'error', |
139 | | - 'no-nested-ternary': 'warn', |
140 | | - eqeqeq: ['error', 'always', { null: 'ignore' }], |
141 | | - 'no-throw-literal': 'error', |
142 | | - |
143 | | - // JSDoc Rules |
144 | | - // 'jsdoc/check-alignment': 'warn', |
145 | | - // 'jsdoc/check-indentation': 'warn', |
146 | | - |
147 | | - // Playwright recommended rules (from plugin:playwright/playwright-test) |
148 | | - ...playwright.configs['playwright-test'].rules, |
149 | | - |
150 | | - 'playwright/missing-playwright-await': ['error'], |
151 | | - 'playwright/no-focused-test': 'error', |
152 | | - 'playwright/valid-expect': 'error', |
153 | | - 'playwright/prefer-web-first-assertions': 'error', |
154 | | - 'playwright/no-useless-await': 'error', |
155 | | - 'playwright/no-page-pause': 'error', |
156 | | - 'playwright/no-element-handle': 'error', |
157 | | - 'playwright/no-eval': 'error', |
158 | | - 'playwright/prefer-to-be': 'error', |
159 | | - 'playwright/prefer-to-contain': 'error', |
160 | | - 'playwright/prefer-to-have-length': 'error', |
161 | | - 'playwright/no-wait-for-timeout': 'warn', |
162 | | - 'playwright/no-useless-not': 'warn', |
163 | | - 'playwright/require-top-level-describe': 'off', |
164 | | - 'playwright/expect-expect': 'off', |
165 | | - 'playwright/no-conditional-in-test': 'off', |
166 | | - 'playwright/no-skipped-test': 'off', |
167 | | - 'playwright/consistent-spacing-between-blocks': 'off', |
168 | | - }, |
169 | | - }, |
| 33 | + ...playwrightLibConfig, |
| 34 | + // Project-specific rule overrides |
| 35 | + { rules: { 'playwright/no-focused-test': 'warn' } }, |
170 | 36 | ]; |
0 commit comments