-
Notifications
You must be signed in to change notification settings - Fork 671
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
Webpack parser and rule #957
Conversation
.eslintignore
Outdated
@@ -1,3 +1,5 @@ | |||
coverage | |||
dist | |||
node_modules | |||
fixtures | |||
packages/rule-webpack-config/README.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is ESLint looking at this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eslint look at all the md files and check the js/ts code.
In this case, I have an intentional error in the code, and I don't want Eslint to fail :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
@@ -1,3 +1,5 @@ | |||
coverage | |||
dist | |||
node_modules | |||
fixtures | |||
packages/rule-webpack-config/docs/is-valid.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarvaje Can this be moved in a .eslintignore
file in packages/rule-webpack-config/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to try it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't do that, we are using only this .eslintignore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if you create another .eslintignore
in there it doesn't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the only thing we can do is copy/paste this file to the folder rule-webpack-config
and modify the package.json script to use that file instead of the one in the root folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's weird, usually ESLint uses the .eslintrc
closest to the resource in combination with the one in the root so I would expect it to do the same with .eslintignore
.
@@ -0,0 +1,71 @@ | |||
# Parser webpack-config (`@sonarwhal/parser-webpack-config`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use
webpack config parser
# Parser webpack-config (`@sonarwhal/parser-webpack-config`) | ||
|
||
The `webpack-config` parser allows the user to analyze the | ||
Webpack configuration in their projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,63 @@ | |||
<!-- markdownlint-disable MD024 --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
@@ -0,0 +1,63 @@ | |||
<!-- markdownlint-disable MD024 --> | |||
|
|||
# webpack-config (`@sonarwhal/rule-webpack-config`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webpack-config
Maybe use a more descriptive title?
@alrra this should be done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First revision, mostly typos. Need to take a deeper look later.
@@ -1,3 +1,5 @@ | |||
coverage | |||
dist | |||
node_modules | |||
fixtures | |||
packages/rule-webpack-config/docs/is-valid.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if you create another .eslintignore
in there it doesn't work?
### Examples that **pass** the rule | ||
|
||
`typescript-config` configured and `complierOptions.module` has | ||
a the value `esnext` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove a
@@ -0,0 +1,43 @@ | |||
/** | |||
* @fileoverview `webpack-config/is-valid` warns again providing an invalid webpack configuration file `webpack.config.js`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
@@ -0,0 +1,45 @@ | |||
/** | |||
* @fileoverview `webpack-config/no-devtool-in-prod` warns again having set the propety `devtool` to `eval`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
public static readonly meta: RuleMetadata = { | ||
docs: { | ||
category: Category.development, | ||
description: '`webpack-config/no-devtool-in-prod` warns again having set the propety `devtool` to `eval`' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
public static readonly meta: RuleMetadata = { | ||
docs: { | ||
category: Category.development, | ||
description: '`webpack-config/is-installed` warns again not having webpack installed' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
public static readonly meta: RuleMetadata = { | ||
docs: { | ||
category: Category.development, | ||
description: '`webpack-config/is-valid` warns again providing an invalid webpack configuration file `webpack.config.js`' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
@@ -0,0 +1,77 @@ | |||
/** | |||
* @fileoverview `webpack-config/module-esnext-typescript` warns again not having set the propety `compilerOptions.module` to `esnext` in typescript configuration file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
public static readonly meta: RuleMetadata = { | ||
docs: { | ||
category: Category.development, | ||
description: '`webpack-config/module-esnext-typescript` warns again not having set the propety `compilerOptions.module` to `esnext` in typescript configuration file' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
@@ -0,0 +1,82 @@ | |||
/** | |||
* @fileoverview `webpack-config/modules-false-babel` warns again not having set the propety `modules` to `false` in presets in babel configuration file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
against
@molant done |
|
||
## Types | ||
|
||
If you need to import any type defined in this parser, you just need to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove just
.
(see: #939)
package `webpack` is not installed locally. | ||
This event doesn't containt anything else. | ||
|
||
* `parse::webpack-config::error::not-found`. This event is sent if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same observation as in #973 (comment).
(Cc @molant)
* `resource`: the parsed resource. | ||
* `error`: the error emited parsing the configuration file. | ||
|
||
* `parse::webpack-config::error::not-install`. This event is sent if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be the job of the parser?
(Cc @molant)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarvaje You will do the changes in another PR, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes :)
"webpack-config" | ||
], | ||
"license": "Apache-2.0", | ||
"main": "dist/src/webpack-config.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use parser.js
.
const resource = fetchEnd.resource; | ||
const fileName = path.basename(resource); | ||
|
||
if (fileName !== 'webpack.config.js') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only place the configs can be placed in?
Can you provide a link for this? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find any reference about another place to have the webpack config. Do you think I should add this link? https://webpack.js.org/configuration/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alrra this is done!
@@ -0,0 +1,18 @@ | |||
# `config-exists` (`webpack-config/config-exists`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe drop (webpack-config/config-exists)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you want me to do that in the other rules doc files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
c77e951
to
3b2a2fe
Compare
3671da3
to
3d388bc
Compare
Pull request checklist
Make sure you:
For non-trivial changes, please make sure you also:
Short description of the change(s)