ESLint print all fixes to terminal - eslint

When I run ESLint with the --fix flag, I'd like for the changes made to be output to the terminal. By default it displays no output except for errors or warnings that cannot be fixed, as the ESLint docs say:
The fixes are made to the actual files themselves and only the remaining unfixed issues are output.
Is there any way to force ESLint to print all the issues that were fixed to the terminal?
For the sake of clarity, here's the command I'm currently running: eslint src --fix --ext js,ts,tsx.

Related

How can I solve the prettier/prettier problem

I'm using nuxtjs, and I installed eslint on my project, and upon using npm run dev, I get a bombardment of errors. How can I fix this:
This error is related to Windows Line endings being different from Unix ones. Try running npx prettier --write . on your project's directory. This command will tell prettier to fix simple errors (such as this one) when found.
To prevent this error from happening again you can either set "end-of-line" to auto on your .prettierrc file or try setting line endings to "Unix"/LF on your editor: instructions for VSCode and for IntelliJ-based editors

ESLint config for unused var

Is it possible to fix all ESLint warning by CLI ?
I've try this, but don't fix all error (unused var for example) :
eslint --fix src
As the old adage goes, "RTFM".
See: https://eslint.org/docs/user-guide/command-line-interface#fixing-problems
--fix
This option instructs ESLint to try to fix as many issues as possible. The fixes are made to the actual files themselves and only the remaining unfixed issues are output. Not all problems are fixable using this option, and the option does not work in these situations:
This option throws an error when code is piped to ESLint.
This option has no effect on code that uses a processor, unless the
processor opts into allowing autofixes.

Running script in package.json works but includes errors

I just installed ESLint and I can successfully run it by doing this at the terminal window:
./node_modules/.bin/eslint app
Note: app is the root folder I want lint to inspect.
I then put that exact command in my package.json:
"scripts": {
"lint": "./node_modules/.bin/eslint app"
}
I expected to be able to run it in the terminal window like this:
npm run lint
Note: I know how to fix the no-undef error. My question is about the many errors lines after that.
It actually works, but it also produces a bunch of errors after showing me the correct output:
Why is that happening?
This is the default way of how the npm script runner handles script errors (i.e. non-zero exit codes). This will always happen, even if you only run a script like exit 1.
I'm not sure why this feature exists, it seems annoying and useless in most cases.
If you don't want to see this, you can add || true at the end of your script.
Example:
lint: "eslint app || true"
As you might've noticed, I've omitted the part to the eslint binary. The npm script runner already includes local binaries as part of the path when trying to run the script so there is no need to use the full path.
document is a global, so eslint thinks you are missing an import somewhere. For those cases, you can adapt your config so that the error is not reported, Something like this:
module.exports = {
"globals": {
"document": true
}
}
this should be saved as .eslintrc.js and be at the same level where your package.json is

node-sass cli not compiling on initial run when using --watch

So when running the following command I'm expecting node-sass to compile and start watching. If I have to run a separate node-sass -w command wouldn't I have to include all the same parameters I included on the first? Seems like an odd way of doing things.
node-sass app/styles -o app/styles --source-map true --include-path app/bower_components --quiet --watch
Actually watch triggers compilation each and every time the file changes, as the (sass) documentation states:
You can also tell Sass to watch the file and update the CSS every time the Sass file changes: [...]
However, the documentation says nothing about what happens when the watch process starts, which is what led you to expect it to compile right after being invoked.
It's, for sure, an odd way of doing things.

ESLint: What does it mean if a rule is fixable?

According to ESLint: Docs: Rules,
Some rules are fixable using the --fix command line flag.
What does that mean?
Running the command eslint --help, tells us that the --fix command line flag "automatically fix[es] problems."
ESLint: Docs: User Guide: Command Line Interface: --fix provides more explanation:
This option instructs ESLint to try to fix as many issues as possible.
The fixes are made to the actual files themselves and only the
remaining unfixed issues are output. Not all problems are fixable
using this flag, and the flag does not work in these situations:
This option throws an error when code is piped to ESLint.
This option has no effect on code that uses processors.

Resources