|
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 | + * This repo's ESLint config: base config + local overrides. |
| 3 | + * Edit eslint.config.base.js to change rules; that file is also published as vasu-playwright-utils/eslint. |
| 4 | + */ |
| 5 | +const base = require('./eslint.config.base.js'); |
8 | 6 |
|
9 | 7 | module.exports = [ |
10 | | - { ignores: ['node_modules/**', '.husky/**', '**/*.js', 'package-lock.json', 'dist/**/*'] }, |
11 | | - js.configs.recommended, |
12 | | - { |
13 | | - files: ['**/*.ts'], |
14 | | - languageOptions: { |
15 | | - parser: typescriptParser, |
16 | | - parserOptions: { project: './tsconfig.json', tsconfigRootDir: __dirname }, |
17 | | - globals: { |
18 | | - console: 'readonly', |
19 | | - process: 'readonly', |
20 | | - Buffer: 'readonly', |
21 | | - __dirname: 'readonly', |
22 | | - __filename: 'readonly', |
23 | | - global: 'readonly', |
24 | | - module: 'readonly', |
25 | | - require: 'readonly', |
26 | | - exports: 'readonly', |
27 | | - }, |
28 | | - }, |
29 | | - plugins: { |
30 | | - '@typescript-eslint': typescript, |
31 | | - prettier: prettier, |
32 | | - import: importPlugin, |
33 | | - jsdoc: jsdoc, |
34 | | - playwright: playwright, |
35 | | - }, |
36 | | - settings: { 'import/resolver': { typescript: { alwaysTryTypes: true } } }, |
37 | | - rules: { |
38 | | - // Prettier Rules |
39 | | - 'prettier/prettier': 'error', |
40 | | - 'no-trailing-spaces': 'error', |
41 | | - 'no-multiple-empty-lines': ['error', { max: 1, maxEOF: 0 }], |
42 | | - 'eol-last': ['error', 'always'], |
43 | | - |
44 | | - // TypeScript Rules - Base |
45 | | - ...typescript.configs['eslint-recommended'].overrides[0].rules, |
46 | | - ...typescript.configs.recommended.rules, |
47 | | - '@typescript-eslint/no-unsafe-assignment': 'warn', |
48 | | - '@typescript-eslint/no-unsafe-member-access': 'warn', |
49 | | - '@typescript-eslint/no-unsafe-return': 'warn', |
50 | | - '@typescript-eslint/no-unsafe-call': 'warn', |
51 | | - '@typescript-eslint/no-floating-promises': 'error', |
52 | | - '@typescript-eslint/no-unnecessary-type-assertion': 'error', |
53 | | - '@typescript-eslint/no-explicit-any': 'warn', |
54 | | - '@typescript-eslint/explicit-module-boundary-types': 'off', |
55 | | - |
56 | | - // TypeScript Rules - Additional Strict Rules |
57 | | - '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }], |
58 | | - '@typescript-eslint/no-unused-expressions': 'error', |
59 | | - '@typescript-eslint/no-empty-function': 'warn', |
60 | | - '@typescript-eslint/prefer-nullish-coalescing': 'error', |
61 | | - '@typescript-eslint/prefer-optional-chain': 'error', |
62 | | - '@typescript-eslint/prefer-as-const': 'error', |
63 | | - '@typescript-eslint/no-non-null-assertion': 'warn', |
64 | | - '@typescript-eslint/no-duplicate-enum-values': 'error', |
65 | | - '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: false, ignoreProperties: false }], |
66 | | - |
67 | | - // Import Rules |
68 | | - 'import/no-unresolved': 'error', |
69 | | - 'import/named': 'error', |
70 | | - 'import/default': 'error', |
71 | | - 'import/no-absolute-path': 'error', |
72 | | - 'import/no-self-import': 'error', |
73 | | - // 'import/no-duplicates': 'error', |
74 | | - 'import/first': 'error', |
75 | | - 'import/no-mutable-exports': 'error', |
76 | | - 'sort-imports': ['error', { ignoreDeclarationSort: true }], |
77 | | - |
78 | | - // General Rules - Best Practices |
79 | | - 'require-await': 'off', // Turned off in favor of @typescript-eslint version |
80 | | - '@typescript-eslint/require-await': 'error', |
81 | | - '@typescript-eslint/await-thenable': 'error', |
82 | | - '@typescript-eslint/no-misused-promises': 'error', |
83 | | - complexity: ['warn', { max: 11 }], |
84 | | - 'no-console': ['warn', { allow: ['warn', 'error', 'info'] }], |
85 | | - 'no-debugger': 'error', |
86 | | - 'no-var': 'error', |
87 | | - 'prefer-const': 'error', |
88 | | - 'prefer-template': 'error', |
89 | | - 'object-shorthand': 'error', |
90 | | - // 'no-else-return': ['error', { allowElseIf: false }], |
91 | | - 'no-lonely-if': 'error', |
92 | | - 'no-useless-return': 'error', |
93 | | - 'no-nested-ternary': 'warn', |
94 | | - eqeqeq: ['error', 'always', { null: 'ignore' }], |
95 | | - 'no-throw-literal': 'error', |
96 | | - |
97 | | - // JSDoc Rules |
98 | | - 'jsdoc/check-alignment': 'warn', |
99 | | - 'jsdoc/check-indentation': 'warn', |
100 | | - |
101 | | - // Playwright recommended rules (from plugin:playwright/playwright-test) |
102 | | - ...playwright.configs['playwright-test'].rules, |
103 | | - |
104 | | - // Playwright Rules |
105 | | - 'playwright/missing-playwright-await': ['error'], |
106 | | - 'playwright/no-focused-test': 'error', |
107 | | - 'playwright/valid-expect': 'error', |
108 | | - 'playwright/prefer-web-first-assertions': 'error', |
109 | | - 'playwright/no-useless-await': 'error', |
110 | | - 'playwright/no-page-pause': 'error', |
111 | | - 'playwright/no-element-handle': 'error', |
112 | | - 'playwright/no-eval': 'error', |
113 | | - 'playwright/prefer-to-be': 'error', |
114 | | - 'playwright/prefer-to-contain': 'error', |
115 | | - 'playwright/prefer-to-have-length': 'error', |
116 | | - 'playwright/no-wait-for-timeout': 'warn', |
117 | | - 'playwright/no-useless-not': 'warn', |
118 | | - 'playwright/require-top-level-describe': 'off', |
119 | | - 'playwright/expect-expect': 'off', |
120 | | - 'playwright/no-conditional-in-test': 'off', |
121 | | - 'playwright/no-skipped-test': 'off', |
122 | | - 'playwright/consistent-spacing-between-blocks': 'off', |
123 | | - }, |
124 | | - }, |
| 8 | + ...base, |
| 9 | + // Repo-specific: JSDoc alignment/indentation as warn (base has them off for consumers) |
| 10 | + { rules: { 'jsdoc/check-alignment': 'warn', 'jsdoc/check-indentation': 'warn' } }, |
| 11 | + // Repo-specific: stricter module boundary types in src |
125 | 12 | { files: ['src/**/*.ts'], rules: { '@typescript-eslint/explicit-module-boundary-types': 'warn' } }, |
126 | 13 | ]; |
0 commit comments