Skip to content

Commit 954980d

Browse files
committed
eslint config
1 parent ea9e33b commit 954980d

2 files changed

Lines changed: 15 additions & 25 deletions

File tree

.eslintrc.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,17 @@ module.exports = {
2929
}
3030
},
3131
{
32-
'files': ['*.ts', '!*.spec.ts', '!*.test.ts', '!*.tests.ts', '!*.test-d.ts'],
33-
'excludedFiles': ['**/__mocks__/**', '**/tests/**'],
32+
'files': ['lib/**/*.ts', 'src/**/*.ts'],
33+
'excludedFiles': [
34+
'**/*.spec.ts',
35+
'**/*.test.ts',
36+
'**/*.tests.ts',
37+
'**/*.test-d.ts',
38+
'**/*.gen.ts',
39+
'**/*.d.ts',
40+
'**/__mocks__/**',
41+
'**/tests/**'
42+
],
3443
'rules': {
3544
'local-rules/require-platform-declaration': 'error',
3645
}

eslint-local-rules/require-platform-declaration.js

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/**
22
* ESLint Rule: require-platform-declaration
33
*
4-
* Ensures that all non-test source files export __platforms with valid platform values
4+
* Ensures that all source files export __platforms with valid platform values.
5+
*
6+
* File exclusions (test files, generated files, etc.) should be configured
7+
* in .eslintrc.js using the 'excludedFiles' option.
58
*
69
* Valid:
710
* export const __platforms = ['browser'];
@@ -51,28 +54,6 @@ module.exports = {
5154
},
5255

5356
create(context) {
54-
const filename = context.getFilename();
55-
56-
// Skip test files
57-
if (filename.endsWith('.spec.ts') ||
58-
filename.endsWith('.test.ts') ||
59-
filename.endsWith('.tests.ts') ||
60-
filename.endsWith('.test.js') ||
61-
filename.endsWith('.spec.js') ||
62-
filename.endsWith('.tests.js') ||
63-
filename.endsWith('.test-d.ts') ||
64-
filename.endsWith('.gen.ts') ||
65-
filename.endsWith('.d.ts') ||
66-
filename.includes('/__mocks__/') ||
67-
filename.includes('/tests/')) {
68-
return {};
69-
}
70-
71-
// Skip non-source files
72-
if (!filename.includes('/lib/') && !filename.includes('/src/')) {
73-
return {};
74-
}
75-
7657
const VALID_PLATFORMS = getValidPlatformsForContext(context);
7758
let hasPlatformExport = false;
7859

0 commit comments

Comments
 (0)