I'm trying to get started using ESLint from this tutorial: https://davidwalsh.name/eslint
I've copied the example file. When I run eslint uploader.js
in its directory, nothing happens - there is a line break, and then the prompt returns. No output at all.
I've run it on a JSON file in the same directory, and used a Grunt task to run it on all JS files project wide. These return a few errors, but nothing near what I'm expecting.
When I run eslint
on the command line, it acts as expected - returning arguments and options documentation. I've tried rebooting the instance, reinstalling ESLint, intentionally introducing egrigious errors into uploader.js
, but nothing happens, much less the output displayed in the tutorial. Can someone help?
You can set up ESLint to run auto-fix every time you press CTRL+S (or COMMAND+S ). For ESLint to work correctly on file same, you must change the Visual Studio Code preferences. Go to File > Preferences > Settings (or Code > Preferences > Settings).
You can tell ESLint to ignore specific files and directories using ignorePatterns in your config files. ignorePatterns patterns follow the same rules as . eslintignore .
If you want to disable an ESLint rule in a file or on a specific line, you can add a comment. On a single line: const message = 'foo'; console. log(message); // eslint-disable-line no-console // eslint-disable-next-line no-console console.
Starting from version 1.0.0 of ESLint, all linting rules are turned off by default.
That tutorial was written before this version, which would have expected some errors to show up without a configuration file. The official website provides a migration guide. In your case, you may wish to extend your ".eslintrc" file with "eslint:recommended" throughout that tutorial (or simply include the intended rules manually). Here's the closest you can get from the previous versions, according to the guide:
{
"extends": "eslint:recommended",
"rules": {
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-empty-label": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-underscore-dangle": 2,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"no-with": 2,
"camelcase": 2,
"comma-spacing": 2,
"consistent-return": 2,
"curly": [2, "all"],
"dot-notation": [2, { "allowKeywords": true }],
"eol-last": 2,
"no-extra-parens": [2, "functions"],
"eqeqeq": 2,
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"new-cap": 2,
"new-parens": 2,
"quotes": [2, "double"],
"semi": 2,
"semi-spacing": [2, {"before": false, "after": true}],
"space-infix-ops": 2,
"space-return-throw-case": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"strict": [2, "function"],
"yoda": [2, "never"]
}
}
Since version 3.0.0, ESLint will refuse to work without a configuration file, printing an error message instead. This will hopefully prevent people from running into this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With