-
-
Notifications
You must be signed in to change notification settings - Fork 27k
feat: react-scripts lint command #1217 #3850
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @remove-on-eject-begin | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
// @remove-on-eject-end | ||
'use strict'; | ||
|
||
const CLIEngine = require('eslint').CLIEngine; | ||
|
||
const cli = new CLIEngine({ | ||
// @remove-on-eject-begin | ||
configFile: require.resolve('eslint-config-react-app'), | ||
// @remove-on-eject-end | ||
fix: process.argv.slice(2).indexOf('--fix') >= 0, | ||
}); | ||
const report = cli.executeOnFiles(['src/**/*.{js,jsx,mjs}']); | ||
const formatter = cli.getFormatter(); | ||
|
||
// persist changed files when using --fix option | ||
CLIEngine.outputFixes(report); | ||
console.log(formatter(report.results)); | ||
|
||
if (report.errorCount > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Condition to trigger Report object has a count of fixable errors and it is possible to count how many unfixed errors are left: {
'...': '...',
errorCount: 1,
fixableErrorCount: 1,
} My concern is that in |
||
process.exit(1); | ||
} |
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.
hardcoding this won't respect the changes that user made in
package.json
or.eslintrc
post eject. IMO we should wrap this line: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 ... but then
react-scripts lint
after eject has few errors: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.
hmm, do you have
eslint
installed globally /.eslintrc
file somewhere in the parent folder? i think we need to addroot: true
toeslintConfig
property inpackage.json
post eject. https://eslint.org/docs/user-guide/configuring#using-configuration-files can you try adding it and see if it fix the problem?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.
Sadly, no change after:
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.
Also adding
plugins: ['jsx-a11y']
to CLIEngine constructor options doesn't remove errors.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 running it with
DEBUG=eslint:* yarn lint
would help you found the problem. I cannot reproduce it locally using the same code :(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.
or
DEBUG=eslint:config* yarn lint
if you just want the log related to config