build: add __tests__ and __mocks__ dirs to relevant parts of eslint-factory
Signed-off-by: MT Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
---
|
||||
'@backstage/cli': minor
|
||||
---
|
||||
|
||||
Treat files in `__tests__` 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 directories named
|
||||
`__tests__` or `__mocks__`, to match the default file locations used in Jest.
|
||||
|
||||
cf.
|
||||
https://jestjs.io/docs/configuration/#testmatch-arraystring
|
||||
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/**/__tests__/**'),
|
||||
joinPath(dir, 'src/**/__mocks__/**'),
|
||||
joinPath(dir, 'src/setupTests.*'),
|
||||
]
|
||||
: [
|
||||
// Legacy config for packages that don't provide a dir
|
||||
'**/*.test.*',
|
||||
'**/*.stories.*',
|
||||
'**/__tests__/**',
|
||||
'**/__mocks__/**',
|
||||
'**/src/setupTests.*',
|
||||
'**/dev/**',
|
||||
],
|
||||
@@ -137,6 +141,8 @@ function createConfig(dir, extraConfig = {}) {
|
||||
// Prevent imports of stories or tests
|
||||
'*.stories*',
|
||||
'*.test*',
|
||||
'**/__tests__/**',
|
||||
'**/__mocks__/**',
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -159,7 +165,14 @@ function createConfig(dir, extraConfig = {}) {
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.test.*', '**/*.stories.*', 'src/setupTests.*', '!src/**'],
|
||||
files: [
|
||||
'**/*.test.*',
|
||||
'**/*.stories.*',
|
||||
'**/__tests__/**',
|
||||
'**/__mocks__/**',
|
||||
'src/setupTests.*',
|
||||
'!src/**',
|
||||
],
|
||||
rules: {
|
||||
...testRules,
|
||||
'no-restricted-syntax': [
|
||||
|
||||
Reference in New Issue
Block a user