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

Support for Typescript #241

Closed
kube opened this issue Aug 29, 2015 · 14 comments

Comments

@kube
Copy link

commented Aug 29, 2015

It would be a good thing to provide support for Typescript files.

@dcousens dcousens added the question label Aug 30, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Aug 30, 2015

Sorry, this would complicate what is currently a simple tool. We only support JavaScript.

@feross feross closed this Aug 30, 2015

@krzkaczor

This comment has been minimized.

Copy link

commented May 1, 2016

I have been working recently on standardTS. https://github.com/krzkaczor/standardts

tslint rules are not so advanced as eslint ones so there's still a lot of work to do but I guess it already provides some value.

@kirillgroshkov

This comment has been minimized.

Copy link

commented Jul 6, 2016

Too bad, I would definitely use it for typescript if possible. Maybe it could be done in some simpler way like stripping down all typescript-specific stuff (like type annotations), other typescript things are based on ES6/7 syntax. Just saying. Using TSLINT now, but 2 problems: not enough rules, a lot of work to write and maintain your own config instead of just using "the only one".

@feross

This comment has been minimized.

Copy link
Member

commented Jul 15, 2016

@kirillgroshkov Maybe standardts or another project can take the approach you describe? I just don't think that typescript support belongs in this repo.

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Mar 1, 2017

Perhaps this will be revisited when ESLint supports different parsers. I've found a love for TypeScript and I'm heart broken about not being able to use standard.
eslint/eslint#6364

@feross

This comment has been minimized.

Copy link
Member

commented Mar 1, 2017

Why don't you just use https://github.com/nzakas/eslint-plugin-typescript ?

{
  "standard": {
     "plugins": [
        "typescript"
    ]
  }
}

That ought to strip type annotations so you can still use standard. Though I haven't tried it myself, since I don't use Typescript.

More complete instructions, but for Flow, are here: https://github.com/feross/standard#can-i-use-a-javascript-language-variant-like-flow

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Mar 4, 2017

Not actually really working. I'll report bugs to eslint-plugin-typescript.
See travis of cycle-components/www#13

@feross

This comment has been minimized.

Copy link
Member

commented Mar 6, 2017

@mightyiam If you figure out that the README instructions are not enough for Typescript, can you please PR to add instructions?

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Mar 7, 2017

If I figure out what to do, I'll surely do so.

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Mar 10, 2017

@eadwu

This comment has been minimized.

Copy link

commented Apr 8, 2017

With this as the test.ts file

let obj: string;
obj = "yo";
// Error: Type 'number' is not assignable to type 'string'.
obj = 10;

function sayIt(what: string) {
    return `Saying: ${what}`;
}
const said: string = sayIt(obj);

class Sayer {
    // mandatory
    what: string;

    constructor(what: string) {
        this.what = what;
    }

    // return type if you want to
    sayIt(): string {
        return `Saying: ${this.what}`;
    }
}

I got the following output

standard: Use JavaScript Standard Style (https://standardjs.com)
standard: Run `standard --fix` to automatically fix some problems.
  $HOME/Downloads/test/test.ts:1:16: Extra semicolon.
  $HOME/Downloads/test/test.ts:2:7: Strings must use singlequote.
  $HOME/Downloads/test/test.ts:2:11: Extra semicolon.
  $HOME/Downloads/test/test.ts:4:9: Extra semicolon.
  $HOME/Downloads/test/test.ts:6:15: Missing space before function parentheses.
  $HOME/Downloads/test/test.ts:7:5: Expected indentation of 2 spaces but found 4.
  $HOME/Downloads/test/test.ts:7:29: Extra semicolon.
  $HOME/Downloads/test/test.ts:9:7: 'said' is assigned a value but never used.
  $HOME/Downloads/test/test.ts:9:32: Extra semicolon.
  $HOME/Downloads/test/test.ts:11:7: 'Sayer' is defined but never used.
  $HOME/Downloads/test/test.ts:13:5: Expected indentation of 2 spaces but found 4.
  $HOME/Downloads/test/test.ts:15:5: Expected indentation of 2 spaces but found 4.
  $HOME/Downloads/test/test.ts:15:16: Missing space before function parentheses.
  $HOME/Downloads/test/test.ts:16:9: Expected indentation of 6 spaces but found 8.
  $HOME/Downloads/test/test.ts:16:25: Extra semicolon.
  $HOME/Downloads/test/test.ts:20:5: Expected indentation of 2 spaces but found 4.
  $HOME/Downloads/test/test.ts:20:10: Missing space before function parentheses.
  $HOME/Downloads/test/test.ts:21:9: Expected indentation of 6 spaces but found 8.
  $HOME/Downloads/test/test.ts:21:38: Extra semicolon.

using the following as my package.json

{
  "devDependencies": {
    "babel-eslint": "^7.2.1",
    "standard": "^10.0.1"
  },
  "standard": {
    "parser": "babel-eslint"
  }
}

and running

node_modules/standard/bin/cmd.js test.ts

How would I add the files to package.json so that it would lint .ts files as well since just running the command without any files only lints .js and .jsx?

@feross

This comment has been minimized.

Copy link
Member

commented Apr 8, 2017

@KC-SI Please open a new issue instead of posting into an already-closed issue. Thanks.

@mightyiam

This comment has been minimized.

Copy link
Contributor

commented Sep 28, 2017

I have released eslint-config-standard-with-typescript. Please report issues and send in PRs. Should be a step forward.

@GantMan

This comment has been minimized.

Copy link

commented Dec 21, 2017

standardts --fix isn't working with missing whitespace.

I'm a fan of standard, and I'm a fan of typescript. Anyone got a fix for this?

@lock lock bot locked as resolved and limited conversation to collaborators May 25, 2018

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