-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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!: Behavior of CLI when no arguments are passed #17644
Conversation
✅ Deploy Preview for docs-eslint canceled.
|
Makes sense to me. |
Fixed up the edge cases. I also made it so |
Let me point out a use case that I think will be negatively impacted by this change. Sometimes people run ESLint only on a subset of files that is calculated dynamically and that could be possibly empty. For example, for performance reasons, some users will want to lint only changed files in a git repo, so they could be running a command like this (reference): eslint --fix $(git diff --name-only HEAD | xargs) After this PR, if a user runs the above command while there are no uncommitted changes, the whole current directory will be linted (or they will get an error if eslintrc is used). |
@fasttime for clarification, you're referring to the flat config behavior, which defaults to I assume that ESLint isn't the only tool people are using in this way. There are a lot of tools that default to |
I'd guess that people are using ESLint like this simply because they were able do it so far. |
I think |
In fact running PS D:\foo> npx jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In D:\foo
8 files checked.
testMatch: **/__tests__/**/*.[jt]s?(x), **/?(*.)+(spec|test).[tj]s?(x) - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 8 matches
testRegex: - 0 matches
Pattern: - 0 matches
But this behavior can be changed with a flag ( PS D:\foo> npx jest --passWithNoTests
No tests found, exiting with code 0 |
It seems that |
Jest is failing without tests because it didn't find any in the directories that it searches by default. It seems like |
TSC Summary: This PR changes the default behavior of the ESLint CLI when no file arguments are passed in. In eslintrc mode, the CLI now reports an error; in flat config mode, the CLI now assumes TSC Questions:
|
Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update. |
@sam3k please be sure to leave comments as to the resolution from the TSC meeting along with removing the "tsc agenda" label. |
Sounds good |
@mdjermanovic this is ready for review |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
When running the CLI without file arguments it silently fails right now. This PR makes the following changes:
Fixes #14308
Is there anything you'd like reviewers to focus on?
To make this work, I changed how
lintFiles()
works in bothESLint
andFlatESLint
. InFlatESLint
, I decided that an empty string and an empty array are the same and should be treated as.
. I'm not sure if that's the right decision, so I'd like to hear some opinions on that.