eslint-webpack-plugin
eslint-webpack-plugin copied to clipboard
No errors generated for files with only types
Bug report
When I run this command:
npx eslint ./src/**/*.ts --config .\eslint.config.mjs
I get this response:
types.ts
1:44 error Strings must use singlequote @stylistic/ts/quotes
But when I run it with webpack plugin like this:
plugins: [
new ESLintPlugin({ files: ['./src/**/*.ts'], extensions: 'ts', configType: 'flat' })
],
I don't get this error via webpack.
The file is like this:
import { MyId } from "../components/ids";
export interface INotifications {
onClick: (myId: MyId) => void;
}
There is a similar issue in eslint plugin: https://github.com/webpack-contrib/eslint-webpack-plugin/issues/233 it says it is completed but still doesn't work for webpack.
Actual Behavior
eslint-webpack-plugin does not generate errors with files having only types and or other things like enum and methods that are not used.
Expected Behavior
It should also generate errors for them.
How Do We Reproduce?
- Create a typescript environment with the latest eslint version.
- Create a file that only contains types. Or classes methods enums that are not being used anywhere else, for example:
import { MyId } from "../components/providers";
export interface INotifications {
onClick: (myId: MyId) => void;
}
export class TestClass {
name: string;
public constructor(name: string) {
this.name = name;
}
public method(): void {
this.getName();
this.setName('');
}
getName(): string {
return this.name;
}
setName(name: string): void {
this.name = name;
}
}
Add eslint-plugin to webpack:
const ESLintPlugin = require('eslint-webpack-plugin');
const config = {
plugins: [
new ESLintPlugin({ files: ['./src/**/*.ts'], extensions: 'ts', configType: 'flat' })
],
....
Eslint.config.js:
...
rules: {
"@typescript-eslint/explicit-member-accessibility": ...,
"@stylistic/ts/quotes": ["error", "single", {
avoidEscape: true,
}],
...
}
It does not generate error for that file.
Both webpack and eslint is latest version
Please paste the results of npx webpack-cli info here, and mention other relevant information
System:
OS: Windows 10
Don't want to share other details, all of the packages are the latest