Skip to content

Commit f3f777f

Browse files
committed
Disable ESM-only rules rules for __mocks__ directory
1 parent addb674 commit f3f777f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/configs/javascript.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
GENERATED_FILE_PATTERNS,
1414
JS_TS_JSON_FILE_PATTERNS,
1515
JSON_FILE_PATTERNS,
16+
MOCKS_FILE_PATTERNS,
1617
SVELTE_FILE_PATTERN,
1718
TEST_FILE_PATTERNS,
1819
} from '../lib/patterns.js';
@@ -210,14 +211,25 @@ export default tseslint.config(
210211
'max-nested-callbacks': ['warn', { max: 10 }],
211212
},
212213
},
214+
{
215+
name: 'code-pushup/javascript/mocks/disabled',
216+
files: MOCKS_FILE_PATTERNS,
217+
rules: {
218+
'import/no-commonjs': 'off',
219+
'unicorn/prefer-module': 'off',
220+
'@typescript-eslint/no-require-imports': 'off',
221+
},
222+
},
213223
{
214224
name: 'code-pushup/javascript/configs/disabled',
215225
files: CONFIG_FILE_PATTERNS,
216226
rules: {
217227
'import/no-anonymous-default-export': 'off',
218228
'import/no-unassigned-import': 'off',
229+
'import/no-commonjs': 'off',
219230
'unicorn/no-abusive-eslint-disable': 'off',
220231
'unicorn/prefer-module': 'off',
232+
'@typescript-eslint/no-require-imports': 'off',
221233
},
222234
},
223235
{
@@ -246,9 +258,9 @@ export default tseslint.config(
246258
name: 'code-pushup/javascript/cjs/disabled',
247259
files: COMMONJS_FILE_PATTERNS,
248260
rules: {
249-
'@typescript-eslint/no-require-imports': 'off',
250-
'@typescript-eslint/no-var-requires': 'off',
251261
'import/no-commonjs': 'off',
262+
'unicorn/prefer-module': 'off',
263+
'@typescript-eslint/no-require-imports': 'off',
252264
},
253265
},
254266
{

src/lib/patterns.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ export const TEST_FILE_PATTERNS = [
4646
...CONFIG_FILE_PATTERNS,
4747
];
4848

49+
export const MOCKS_FILE_PATTERNS = [fromDirectory('__mocks__')];
50+
4951
// @angular-eslint's inline templates processor transforms .ts files to .html
5052
// https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/src/processors.ts#L164
5153
export const TEST_FILE_PATTERNS_INLINE_TEMPLATES = TEST_FILE_PATTERNS.map(

0 commit comments

Comments
 (0)