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

Add an ingorePath option to the no-unsupported-features rules #97

Closed
pvdlg opened this issue Nov 25, 2017 · 4 comments
Closed

Add an ingorePath option to the no-unsupported-features rules #97

pvdlg opened this issue Nov 25, 2017 · 4 comments

Comments

@pvdlg
Copy link

pvdlg commented Nov 25, 2017

In some cases a project can write both code that will run on Node 4 and code that will be transpiled.

For example ava allow to write test code in es2017.
So for example a project that targets Node 4 will:

  • Have "engines": {"node": ">=4"} in the package.json
  • Sources files ./index.js, ./src, ./bin that are supposed to written for Node 4. Those files must be checked.
  • Test files in ./test that will be transpiled by ava. Those must not be checked.

An ignorePath option would allow to configure the path to ignore (in this case ./test).
In addition it might be a good idea to ignore by default all paths and files not included in the npm package (files properties in package.json + .npmignore).

@mysticatea
Copy link
Owner

mysticatea commented Nov 27, 2017

Thank you for this issue.

I'm not sure that the option is needed because I think you can use overrides property of .eslintrc.* file. For example:

{
    "plugins": ["node"],
    "extends": ["eslint:recommended", "plugin:node/recommended"],
    "rules": {
    },
    "overrides": [
        {
            "files": ["test/**/*.js"],
            "rules": {
                "node/no-unsupported-features": ["error", { "ignores": ["asyncAwait"] }]
            },
        }
    ]
}

The node/no-unsupported-features has ignores option to allow each syntax, so I'm afraid that ignores × ignorePath. The "overrides" feature let us adjust rule options in great detail.

@pvdlg
Copy link
Author

pvdlg commented Nov 28, 2017

Ok, it totally makes sense!

Thinking more about it, maybe it would be a good idea to add an engines option to the rule. The options would have the same format as the one in package.json and it will override the what's configured in package.json.

So in the example of a Node 4 project that uses ava we could configure:

  • the rule with default behavior for the sources
  • the rule with {engines: node: '>=8'} for the test files

The current ignore option is great and allow for very specific control, but it seems that most project do no set Babel transform one by one, but instead use an es version or a node version as a target.

This is especially true since babel-preset-env is the recommended approach.

@mysticatea
Copy link
Owner

@pvdlg
Copy link
Author

pvdlg commented Nov 28, 2017

I'm so sorry...I don't know how I missed that....

I'm gonna close the issue as it's irrelevant. Thanks for the help!

@pvdlg pvdlg closed this as completed Nov 28, 2017
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

No branches or pull requests

2 participants