Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: eslint configuration should be enabled if files passed (#460)
If we pass the `files` option to the `eslint` configuration, it should be enabled by default. This fix also updates documentation of default eslint configuration to prevent common issues. ✅ Closes: #458
- Loading branch information
1 parent
1c2ab8c
commit 7db1c21
Showing
3 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
test/unit/eslint-reporter/EsLintReporterConfiguration.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import webpack from 'webpack'; | ||
import { join } from 'path'; | ||
import { EsLintReporterConfiguration } from '../../../lib/eslint-reporter/EsLintReporterConfiguration'; | ||
import { EsLintReporterOptions } from '../../../lib/eslint-reporter/EsLintReporterOptions'; | ||
|
||
describe('eslint-reporter/EsLintReporterConfiguration', () => { | ||
let compiler: webpack.Compiler; | ||
const context = '/webpack/context'; | ||
|
||
const configuration: EsLintReporterConfiguration = { | ||
enabled: false, | ||
memoryLimit: 2048, | ||
options: { | ||
cwd: context, | ||
extensions: ['.ts', '.tsx', '.js', '.jsx'], | ||
}, | ||
files: [], | ||
}; | ||
|
||
beforeEach(() => { | ||
compiler = { | ||
options: { | ||
context, | ||
}, | ||
} as webpack.Compiler; | ||
}); | ||
|
||
it.each([ | ||
[undefined, configuration], | ||
[{}, configuration], | ||
[ | ||
{ files: 'src/**/*.{js,ts,tsx,jsx}' }, | ||
{ | ||
...configuration, | ||
enabled: true, | ||
files: [join(context, 'src/**/*.{js,ts,tsx,jsx}')], | ||
}, | ||
], | ||
[{ files: [] }, configuration], | ||
[{ enabled: true }, { ...configuration, enabled: true }], | ||
[{ memoryLimit: 512 }, { ...configuration, memoryLimit: 512 }], | ||
])('creates configuration from options %p', async (options, expectedConfiguration) => { | ||
const { createEsLintReporterConfiguration } = await import( | ||
'lib/eslint-reporter/EsLintReporterConfiguration' | ||
); | ||
const configuration = createEsLintReporterConfiguration( | ||
compiler, | ||
options as EsLintReporterOptions | ||
); | ||
|
||
expect(configuration).toEqual(expectedConfiguration); | ||
}); | ||
}); |