Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript linting works only partially #1283

Open
ArmorDarks opened this issue May 24, 2019 · 9 comments

Comments

@ArmorDarks
Copy link

commented May 24, 2019

What version of standard?

v12.0.1

What operating system, Node.js, and npm version?

Window 10
Node v10.15.3
NPM v6.9.0

What did you expect to happen?

Expected to have ability use TypeScript linting

What actually happened?

Following #1278, provided docs are insufficient to make TypeScript linting fully work, since while it will become enabled, due to lack of the TypeScript plugin rules extensions, rules actually won't work (see #1278 (comment)).

More of it, since there is no way to disable no-unused-vars, Standard will always fail on imports of the types.

For now there is no way to make it fully work. False-unsued vars can be fixed by providing within each file

/* eslint no-unused-vars: "off" */
/* eslint @typescript-eslint/no-unused-vars: "error" */

but that doesn't looks like convinient at all.

@shavyg2

This comment has been minimized.

Copy link

commented Jun 4, 2019

just ran into this too

@eladchen

This comment has been minimized.

Copy link
Contributor

commented Jun 10, 2019

Just run into this as well.

@despian

This comment has been minimized.

Copy link

commented Jun 20, 2019

+1 also having problems with this

Another issue I came across is the indentation rules will break under certain circumstances.

You can fix this by adding:

/* eslint indent: off */
/* eslint @typescript-eslint/indent: [error, 2] */

I'm sure there are probably also many other weird edge-case issues.

typescript-eslint does provide a set of sane rules recommended.json but it's not possible to enable these when using standard.

Also, some of these rules aren't really compatible with the standard rules. E.g.

    "@typescript-eslint/indent": "error"  // defaults to 4 space

It would be nice if typescript had proper "no config needed" support in standard.

Maybe the standard project could include their own set of sane defaults for typescript which are compatible with the normal js rules and apply them if the typescript plugin is loaded.

If I were to submit a PR along these lines is it likely it would be accepted?

@despian

This comment has been minimized.

Copy link

commented Jun 20, 2019

Actually, the suggestion in #1007 would resolve this.

@despian despian referenced this issue Jun 20, 2019
@bjufre

This comment has been minimized.

Copy link

commented Jul 3, 2019

Any news here? This would make life much easier...

roocky-one added a commit to roocky-lab/typescript-project-guidelines that referenced this issue Jul 5, 2019

@PandawanFr

This comment has been minimized.

Copy link

commented Aug 10, 2019

Any updates?

I thought I could just add this to my standard config but I get no-unused-vars.

"parser": "@typescript-eslint/parser",
"plugins": [
  "@typescript-eslint/eslint-plugin"
]

I know we can use eslint-config-standard-with-typescript but I think it'd be nice if it was supported by default in standard. I guess we have to wait for #1007 and/or #1321

@feross

This comment has been minimized.

Copy link
Member

commented Aug 11, 2019

I'd like to have solve this in a future version of standard. In the meantime, you can use standardx:

  1. npm install standardx
  2. Rename the "standard" field in your package.json to "standardx"
  3. Add a new "rules": [] section with the following rules:
"rules": {
  "no-unused-vars": "off",
  "@typescript-eslint/no-unused-vars": "error"
}
@ArmorDarks

This comment has been minimized.

Copy link
Author

commented Aug 12, 2019

@feross Thanks for the reply

That was plan B, but it wasn't possible because standardx didn't work with VS Code extension. Now since you've merged standard/vscode-standardjs#71 that should become possible after release.

@ndom91

This comment has been minimized.

Copy link

commented Aug 14, 2019

@feross would it make sense to open an issue on Typescript support in general and maybe even pin it? People can weigh in on what the best path forward would be (out of the box support, plugin, etc.), which rules to include, etc. etc.

EDIT: Sorry just saw your new issue 'Making standard easier to use' which covers a lot of the typescript stuff.

@feross feross pinned this issue Aug 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
8 participants
You can’t perform that action at this time.