Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some files are ignored #120

Closed
NZhuravlev opened this issue Sep 28, 2021 · 9 comments
Closed

Some files are ignored #120

NZhuravlev opened this issue Sep 28, 2021 · 9 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@NZhuravlev
Copy link

  • Operating System: macOS Big Sur 11.5.2
  • Node Version: v14.17.6
  • NPM Version: 6.14.15
  • webpack Version: 4.46.0
  • eslint-webpack-plugin Version: 2.5.4

Expected Behavior

Errors in all the specified folders should be reported.

Actual Behavior

With either

new ESLintPlugin({
	files: ["src", "api-examples"],
	extensions: [".ts"],
	emitWarning: true,
	emitError: true,
	failOnWarning: true,
}),

or

new ESLintPlugin({
	extensions: [".ts"],
	emitWarning: true,
	emitError: true,
	failOnWarning: true,
}),

errors in the api-examples (one of the folders in the project) are not getting reported.

Code

eslintignore:

npm-api/*

.eslintrc.js:

module.exports = {
	"parser": "@typescript-eslint/parser",
	"parserOptions": {
		"ecmaVersion": 6,
		"sourceType": "module",
		"project": "./tsconfig.eslint.json",
		"tsconfigRootDir": __dirname
	},
...

tsconfig.eslint.json:

{
        ...
	"include": [
		"src/**/*.ts",
		"api-examples/**/*.ts"
	],
	"exclude": [
		"npm-api"
	]
}

How Do We Reproduce?

If I were to guess it's about setting up a ts project with similar rules. api-examples folder files here are not used by webpack while compiling - it might be a problem. The documentation says it's possible to lint files outside the compiler context.

@rklos
Copy link

rklos commented Oct 19, 2021

I have the same problem. All of my .d.ts files are ignored even if they're imported in my runtime code.
Repro repo: https://github.com/rklos/nuxtjs-eslint-module-issue-example
IFooBar should be reported as wrong name of interface.
I'm using nuxtjs in this project and it uses eslint-webpack-plugin at version "^2.4.1".

Running eslint directly via CLI command reports all errors without exceptions.

@ricardogobbosouza ricardogobbosouza added the bug Something isn't working label Oct 26, 2021
@ricardogobbosouza
Copy link
Collaborator

@NZhuravlev thanks for reporting and @rklos thanks for example.

For some reason the webpack is not included the d.ts files on the graph.

@alexander-akait, @jsg2021 any idea?

@alexander-akait
Copy link
Member

alexander-akait commented Oct 26, 2021

Oh, ts-loader here, they are emitted as assets, i.e. out of graph (to be honestly I think it is expected, we don't use .d.ts in graph), in theory we can lint emitted assets, but it should be under option

@ricardogobbosouza
Copy link
Collaborator

An option to lint files out of graphic should be interesting

@ricardogobbosouza ricardogobbosouza added the enhancement New feature or request label Oct 26, 2021
@jsg2021
Copy link
Contributor

jsg2021 commented Oct 26, 2021

At that point, you should just use eslint directly and run it on your files via cli/watch... kinda out of scope for this plugin wouldn't you think?

@NZhuravlev
Copy link
Author

Yeah, then it's just easier to lint everything with eslint directly, otherwise, you need 2 different configurations to do more or less the same job. I can't say whether it's in the scope of the plugin but IMO it should be clarified in the documentation.

@ricardogobbosouza
Copy link
Collaborator

Having an option to lint some files out of graph, ino case of .d.ts files make sense even if it's out of scope, this can avoid duplicate settings.
@alexander-akait wdyt?

@alexander-akait
Copy link
Member

alexander-akait commented Oct 26, 2021

Honestly - yes, I think even more linting and formatting are out of scope bundling, we have these package only because it is still popular, but I don't want to sacrifice perf, just setup CI and run eslint/stylelint/prettier/etc on CI before merge, just my opinion

@riteshjagga
Copy link

riteshjagga commented Apr 22, 2022

It would be nice to have them in the scope of the plugin. We have a case where our spec files are in different directory than the src files but would like to have spec files follow consistent styling too.

Eslint can be directly used to lint multiple directories (src, spec or any other directories) but that would mean that we'll need to connect the eslint failures to fail the webpack compilation too somehow, which I do not know how to do it, at the time of writing.

This plugin brings the benefit of failing the webpack compilation (which was one of the big reason it was chosen for our project) in case of any linting errors and developers are then enforced by the means of errors to fix them which brings consistent styling, which means less reviewer efforts on the code reviews.

We needed it before code changes could go to CI to save the turn around time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants