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

Webpack parser and rule #957

Closed
wants to merge 6 commits into from
Closed

Conversation

sarvaje
Copy link
Contributor

@sarvaje sarvaje commented Mar 30, 2018

Pull request checklist

Make sure you:

For non-trivial changes, please make sure you also:

  • Added/Updated related documentation.
  • Added/Updated related tests.

Short description of the change(s)

.eslintignore Outdated
@@ -1,3 +1,5 @@
coverage
dist
node_modules
fixtures
packages/rule-webpack-config/README.md
Copy link
Contributor

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?

Copy link
Contributor Author

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 :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok.

@webhintio webhintio deleted a comment from sarvaje Mar 31, 2018
@@ -1,3 +1,5 @@
coverage
dist
node_modules
fixtures
packages/rule-webpack-config/docs/is-valid.md
Copy link
Contributor

@alrra alrra Apr 2, 2018

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/?

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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`)
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack

(It seems they use webpack instead of Webpack)

Can you make this change everywhere? Thanks!

@@ -0,0 +1,63 @@
<!-- markdownlint-disable MD024 -->
Copy link
Contributor

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`)
Copy link
Contributor

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?

@sarvaje
Copy link
Contributor Author

sarvaje commented Apr 2, 2018

@alrra this should be done!

Copy link
Member

@molant molant left a 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
Copy link
Member

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`
Copy link
Member

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`.
Copy link
Member

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`.
Copy link
Member

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`'
Copy link
Member

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'
Copy link
Member

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`'
Copy link
Member

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.
Copy link
Member

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'
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

against

@sarvaje
Copy link
Contributor Author

sarvaje commented Apr 6, 2018

@molant done


## Types

If you need to import any type defined in this parser, you just need to
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor

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?

Copy link
Contributor Author

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",
Copy link
Contributor

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') {
Copy link
Contributor

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!

Copy link
Contributor Author

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/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me.

Copy link
Contributor Author

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`)
Copy link
Contributor

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)?

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@sarvaje sarvaje force-pushed the webpack-parser branch 3 times, most recently from c77e951 to 3b2a2fe Compare April 10, 2018 16:28
@sarvaje sarvaje force-pushed the webpack-parser branch 2 times, most recently from 3671da3 to 3d388bc Compare April 10, 2018 19:54
@alrra alrra closed this in df50c5f Apr 10, 2018
@sarvaje sarvaje deleted the webpack-parser branch May 10, 2018 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants