4

With eslint you can run it as script with:

scripts: {
  lint: "node ./node_modules/eslint/bin/eslint.js --ext .js",
}

I've changed to typescript and are using typescript-eslint-parser. Works in webstorm. But how do I run it as script? Changing extension to .ts is not working

  lint: "node ./node_modules/eslint/bin/eslint.js --ext .ts",

The error: error Missing file extension "ts" for "../controller/..

6
  • Regarding the documentation, in your ESLint configuration file, you should use "parser": "typescript-eslint-parser". Is that what you mean when you say that you change to typescript-eslint-parser? Commented Mar 23, 2018 at 9:53
  • Shouldn't you just use tslint instead then? Commented Mar 23, 2018 at 9:54
  • @NicolasCami. Changed from javscript to typescript and using "parser": "typescript-eslint-parser" Commented Mar 23, 2018 at 9:59
  • @H.B. No. Eslint is more mature. Commented Mar 23, 2018 at 10:00
  • Did you add "plugins": ["typescript"] in your ESLint configuration file? Commented Mar 23, 2018 at 10:12

1 Answer 1

3
+75

The issue is that you are missing a required parameter. If you run with your existing config it will give below output

$ npm run lint

> node ./node_modules/eslint/bin/eslint.js --ext .ts

eslint [options] file.js [file.js] [dir]

The file or directory is required. So either change it to

scripts: {
  lint: "node ./node_modules/eslint/bin/eslint.js --ext .ts index.ts",
}

Which is for a specific file, or if you want all ts files then use

scripts: {
  lint: "node ./node_modules/eslint/bin/eslint.js --ext .ts .",
}
Sign up to request clarification or add additional context in comments.

4 Comments

I get "error Missing file extension "ts" for "../controller..."
Can you edit the question and post the complete exception in there? @Per
Yes. I've added.
You probably will have to provide a minimal git repo to debug this. It may be that there some file that is causing the issue. The error message though is not helpful for someone else to debug it for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.