I've benn using w0rp/ale for linting with eslint.
I've switched to tslint and the linting stopped working. I have the tslint npm package installed and have tslint.json confing file. Is there something I need to do or should check?
Thank you very much.
Related
I am using npm 8.5.0 and node v16.14.2 on a big project. When I run eslint, I can choose to run it without npx, or I can run it with npx. There doesn't seem to be any difference. I'm writing some npm scripts that run eslint and I don't know whether to write npx eslint or eslint.
What is the difference between running npx eslint and eslint?
npx will download and run the package and is meant for interactive use where you just want to use a tool from the npm registry.
You shouldn't use it in your package.json's scripts section; instead just make sure the desired version of eslint is in your package's dev dependencies and use "eslint" in the scripts, so you're certain to use the correct version.
When I create a new React app via the npx create-react-app my-app command, linting errors do not get flagged within the editor. They still appear in the terminal when the app is run of course.
create-react-app: v.5.0.0
react: v.17.0.2
npm: v.8.1.2
editor: Atom v.1.60.0
Atom Linting Packages:
jsonlint v.1.1.4
linter v3.4.0
linter-eslint 9.0.0
linter-ui-default 3.4.1
Any ideas of why this might be?
Note: I've got other projects linting properly with Atom, just not sure why base CRA does not lint.
I would like to configure my GLOBAL eslint installation to lint my typescript project in Visual Studio Code.
So I installed the Visual Studio Code extension "ESLint" and installed ESLint with
npm install -g eslint
According to https://www.npmjs.com/package/#typescript-eslint/eslint-plugin it is required to install #typescript-eslint/eslint-plugin globally as well, so I ran
npm install -g #typescript-eslint/parser #typescript-eslint/eslint-plugin
to install it together with the ts parse #typescript-eslint/parser.
Next, I added a very simple .eslintrc-file:
{
"parser": "#typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": { }
}
However, as soon as I run eslint . in my project directoy I get:
Error: Failed to load parser '#typescript-eslint/parser' declared in '.eslintrc.js': Cannot find module '#typescript-eslint/parser'
Next I tried removing the globally installed parser and install it locally, yet this won't work neither: Now my global eslint installation can find my local parser, but the parser needs yet another local installation of typescript, eslint etc. I want to run everything globally, though.
I simply can't get it to work! Can anyone help me with the process?
Here are some suggestions...
In your .eslintrc you haven't specified the '#typescript-eslint' plugin...
"plugins": ["#typescript-eslint"],
Also, if you get this working you will also want to specify parserOptions.project & tsconfigRootDir with an absolute path because finding your tsconfig.json - so that you can use the rules that require type info - is harder from a global install.
Also, I think you need to explicitly tell the eslint plugin to validate your TS files (and maybe js and react etc., as desired) with vsc settings....
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
BUT, I fear the whole thing is an uncertain undertaking.... note that the docs say...
It is also possible to install ESLint globally rather than locally
(using npm install eslint --global). However, this is not recommended,
and any plugins or shareable configs that you use must be installed
locally in either case.
I'm noting here that global installs are not recommended, but also that this quote seems to contradict the reference you noted that said to install the plugin globally. I'm not sure which is right as I've stopped setting it up this way since it isn't recommended. Hope this helps never-the-less.
I had an old version of eslint:
eslint -v
v4.5.0
To update eslint I ran:
npm install -g eslint
The response said that eslint#5.9.0 had been installed successfully. Following the instructions in the documentation in my project root I ran
eslint --init
I selected the Google style guide. The install said
The style guide "google" requires eslint#>=5.4.0. You are currently using eslint#4.5.0.
Do you want to upgrade? (Y/n)
That seemed odd, as I'd just installed 5.9.0, but I said Yes. The response said that the installation was successful:
Successfully created .eslintrc.json file in /Users/TDK/LanguageTwo
ESLint was installed locally. We recommend using this local copy instead of your globally-installed copy.
Then I ran
eslint -v
v4.5.0
I checked echo $PATH and didn't see anything like eslintvm locking in an old version.
I tried to lint a file and got this error message:
Error: Cannot find module 'eslint-config-google'
eslint v5.9.0 is now installed locally in my project root and I can see eslint-config-google in the node modules. eslint 5.9.0 is installed globally. My guess is that the "missing" eslint-config-google is because my computer is still running eslint v4.5.0. I restarted my computer. What is keeping eslint at v4.5.0?
I used find . -name 'eslint' to remove every copy of eslint from every directoty. npm uninstall -g eslint didn't remove every module. Then I reinstalled eslint and ran eslint init. Now it's at v5.9.0. It still has the error
Error: Cannot find module 'eslint-config-google'
I don't know what's causing this problem.
I have globaly installed eslint using npm : npm install -g eslint, then I setup a configuration file eslint --init by answering the questions as follow :
? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? Airbnb
? Do you use React? No
? What format do you want your config file to be in? JavaScript
I tried to run eslint on my app.js file eslint app.jsIt doesn't work
I tried to run it doing so : node_modules\.bin\eslint app.js but Ican't eslint file under \node_modules.bin
NPM Version 5.6.0
Node Version 8.10.0
Seeing the error you have just mentioned after trying:
eslint --debug app.js
You need to globally install the eslint plugin import and the eslint airbnb config plugin.
npm -g install eslint-plugin-import eslint-config-airbnb-base
You need to install said plugin because in the eslint --init configuration you have selected the Airbnb style guide.