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

Fix: Remove default .js from --ext CLI option #13176

Merged
merged 1 commit into from Apr 23, 2020
Merged

Conversation

btmills
Copy link
Member

@btmills btmills commented Apr 12, 2020

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

What is the purpose of this pull request? (put an "X" next to an item)

[x] Bug fix (template)

Tell us about your environment

  • ESLint Version: 7.0.0-alpha.3
  • Node Version: 13.11.0
  • npm Version: 6.13.7

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

Configuration
"use strict";

module.exports = {
    root: true,
    plugins: [
        "markdown",
        "react"
    ],
    extends: ["eslint:recommended"],
    overrides: [
        {
            files: [".eslintrc.js"],
            env: {
                node: true
            }
        },
        {
            files: ["**/*.md"],
            processor: "markdown/markdown"
        },
        {
            files: ["**/*.md/*.jsx"],
            env: {
                browser: true,
                es6: true
            },
            globals: {
                React: false
            },
            extends: ["plugin:react/recommended"],
            parserOptions: {
                ecmaFeatures: {
                    jsx: true
                },
                ecmaVersion: 2015,
                sourceType: "module"
            },
        }
    ]
};

What did you do? Please include the actual source code causing the issue.

# README.md

```jsx
!@#$%^
```
$ eslint README.md

What did you expect to happen?

Because I included md and jsx overrides in .eslintrc.js, ESLint should have seen the syntax error in the Markdown file's JSX code block.

What actually happened? Please include the actual, raw output from ESLint.

No errors were reported.

What changes did you make? (Give an overview)

PR #12677, Breaking: lint overrides files, removed the default .js value from the default CLIEngine options. However, it did not remove the same default value from the --ext option parsed by Optionator. Because of this, when running eslint . without the --ext option, Optionator would insert a default --ext .js value that would be passed on to the CLIEngine. ESLint only lints overrides files if the --ext CLI option is not passed, so the default --ext .js option prevented ESLint from ever reaching the overrides file path checking flow.

Is there anything you'd like reviewers to focus on?

Is this a Fix: or a Breaking:? It's a bug fix because it enables behavior that was supposed to be working already, but it's also a breaking change because it removes a CLI option's default value. Since we're still in prereleases, I went with Breaking: since it won't prevent us from doing anything.

@btmills btmills added bug ESLint is working incorrectly core Relates to ESLint's core APIs and features breaking This change is backwards-incompatible evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Apr 12, 2020
@btmills btmills requested a review from mysticatea April 12, 2020 21:54
@ljharb
Copy link
Sponsor Contributor

ljharb commented Apr 12, 2020

Does this mean that without an overrides including .js files, and without an ext option, eslint won’t lint js by default?

@btmills
Copy link
Member Author

btmills commented Apr 12, 2020

Does this mean that without an overrides including .js files, and without an ext option, eslint won’t lint js by default?

In the absence of an --ext option, ESLint will still lint .js files, and it will now also lint overrides patterns. Check out the docs changes in #12677 for the authoritative version. Instead of applying the .js default at the very beginning of CLI arg parsing, the new FileEnumerator#isTargetPath method lints .js files if the --ext option isn't passed.

@btmills
Copy link
Member Author

btmills commented Apr 12, 2020

For more context, take a look at RFC20. This PR is just a fix for one change that was missed in #12677, which is the PR that implemented the RFC.

@ljharb
Copy link
Sponsor Contributor

ljharb commented Apr 13, 2020

Thanks for clarifying :-) sounds great to me.

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

I think that Fix: is better because it may confuse people if a follow-up appears as "Breaking:" in the 7.0.0 changelog.

PR #12677, `Breaking: lint overrides files`, removed the default `.js`
value from the  default CLIEngine options. However, it did not remove
the same default value from the `--ext` option parsed by Optionator.
Because of this, when running `eslint .` without the `--ext` option,
Optionator would insert a default `--ext .js` value that would be passed
on to the CLIEngine. ESLint only lints `overrides` files if the `--ext`
CLI option is not passed, so the default `--ext .js` option prevented
ESLint from ever reaching the `overrides` file path checking flow.
@btmills btmills changed the title Breaking: Remove default .js from --ext CLI option Fix: Remove default .js from --ext CLI option Apr 14, 2020
@btmills btmills removed the breaking This change is backwards-incompatible label Apr 14, 2020
@kaicataldo kaicataldo merged commit ebc28d7 into master Apr 23, 2020
@kaicataldo kaicataldo deleted the ext-default-js branch April 23, 2020 04:20
@kaicataldo
Copy link
Member

Thanks for contributing!

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 21, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Oct 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants