Mqx
Mqx6mo ago

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
marvinh.
marvinh.6mo ago
To run eslint in deno: deno run -A npm:eslint .
Mqx
MqxOP6mo ago
Does this also work with the ESLint config and all the other stuff? What about custom ESLint Rules and other plugins?
marvinh.
marvinh.6mo ago
yes, it's the exact same as calling npx eslint
Mqx
MqxOP6mo ago
And how can I integrate this with vs code?
marvinh.
marvinh.6mo ago
install the eslint vscode extension
Mqx
MqxOP6mo ago
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
marvinh.
marvinh.6mo ago
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 it
Mqx
MqxOP6mo ago
Okay 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
marvinh.
marvinh.6mo ago
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 rules
Mqx
MqxOP6mo ago
Okay 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?
marvinh.
marvinh.6mo ago
I don't think so, unless you don't care about the eslint vscode extension
Mqx
MqxOP6mo ago
Okay Thanks! All your guidance helped me a lot! 👍🏻