Use ESLint with Deno
Is it possible to use ESLint with Deno? I know that Deno has a build in formatter and linter but the ruleset is kinda small and plug-ins are not supported yet.
Are there any guides out there on how to use ESLint with Deno?
Thanks
12 Replies
To run eslint in deno:
deno run -A npm:eslint .
Does this also work with the ESLint config and all the other stuff? What about custom ESLint Rules and other plugins?
yes, it's the exact same as calling
npx eslint
And how can I integrate this with vs code?
install the eslint vscode extension
Okay but do I not need to install ESLint somehow to work with the extension?
As far as I know the vs code extension requires ESLint to be installed either globally or within node modules
Good point, add
"nodeModulesDir": true
to your deno.json
to make deno create a node_modules
folder in your project directory that vscode extensions can pick up. Then run deno run -A npm:eslint
once to populate itOkay I have done this. node_modules is now present. Hmm looks like I also need to add a package.json to set the type to module so that the export inside the ESLint configuration file works
Okay thanks as far it works for js. I think I now need some plugins for typescript
How can I use/install plugins?
I think I need typescript-eslint to also lint ts files
to install plugins import them in your eslint config and run
deno run -A npm:eslint
again
the eslint docs are a good place to start for how to configure their config and rulesOkay that worked 👍🏻 You are a lifesaver! Thanks!
Yes I know how to configure the rules. I just had problems installing and setting everything up with Deno.
Is there also a way to do all this without a node_modules directory?
I don't think so, unless you don't care about the eslint vscode extension
Okay Thanks!
All your guidance helped me a lot! 👍🏻