Merge pull request #14065 from backstage/add-jest-dirs-to-eslint-factory-overrides
build: add __tests__ and __mocks__ dirs to relevant parts of eslint-factory
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Treat files in `__testUtils__` and `__mocks__` directories as test files for linting
|
||||
purposes.
|
||||
|
||||
Updates the parts of the eslint configuration generator that specify which files
|
||||
should be treated as test code to include any files under two additional
|
||||
directories:
|
||||
|
||||
- `__mocks__`: this is the directory used by Jest[0] for mock code.
|
||||
- `__testUtils__`: a suggested location for utility code executed only when
|
||||
running tests.
|
||||
|
||||
[0]: https://jestjs.io/docs/manual-mocks#mocking-user-modules
|
||||
@@ -96,12 +96,16 @@ function createConfig(dir, extraConfig = {}) {
|
||||
`!${joinPath(dir, 'src/**')}`,
|
||||
joinPath(dir, 'src/**/*.test.*'),
|
||||
joinPath(dir, 'src/**/*.stories.*'),
|
||||
joinPath(dir, 'src/**/__testUtils__/**'),
|
||||
joinPath(dir, 'src/**/__mocks__/**'),
|
||||
joinPath(dir, 'src/setupTests.*'),
|
||||
]
|
||||
: [
|
||||
// Legacy config for packages that don't provide a dir
|
||||
'**/*.test.*',
|
||||
'**/*.stories.*',
|
||||
'**/__testUtils__/**',
|
||||
'**/__mocks__/**',
|
||||
'**/src/setupTests.*',
|
||||
'**/dev/**',
|
||||
],
|
||||
@@ -137,6 +141,8 @@ function createConfig(dir, extraConfig = {}) {
|
||||
// Prevent imports of stories or tests
|
||||
'*.stories*',
|
||||
'*.test*',
|
||||
'**/__testUtils__/**',
|
||||
'**/__mocks__/**',
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -159,7 +165,14 @@ function createConfig(dir, extraConfig = {}) {
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.test.*', '**/*.stories.*', 'src/setupTests.*', '!src/**'],
|
||||
files: [
|
||||
'**/*.test.*',
|
||||
'**/*.stories.*',
|
||||
'**/__testUtils__/**',
|
||||
'**/__mocks__/**',
|
||||
'src/setupTests.*',
|
||||
'!src/**',
|
||||
],
|
||||
rules: {
|
||||
...testRules,
|
||||
'no-restricted-syntax': [
|
||||
|
||||
Reference in New Issue
Block a user