Lit-html: Replace TSLint with ESLint

Created on 24 Jul 2019  路  4Comments  路  Source: Polymer/lit-html

Ad TSLint is being deprecated in favor of ESLint, I want to propose to replace it.
Also, good moment to add pre-commit hook for linting and format.

References

Proposal

Use @typescript-eslint, husky and lint-staged.

package.json

  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.0.0",
    "@typescript-eslint/parser": "^2.0.0",
    "eslint": "^6.2.0",
    "husky": "^3.0.0",
    "lint-staged": "^9.2.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "**/*.{js,ts}": [
      "eslint --fix",
      "git add"
    ]
  }

.eslintrc.json

{
  "extends": [
    "eslint:recommended",
    "plugin:@typescript-eslint/eslint-recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "plugins": [
    "@typescript-eslint"
  ]
}

.eslintignore

/lib/
/directives/
/polyfills/
/test/**/*.{d.ts,d.ts.map,js,js.map}
/tools/lib/
/lit-html.{d.ts,d.ts.map,js,js.map}

Most helpful comment

If there are desirable lint passes in ESLint that aren't in TSLint then I say go for it. Lint errors won't block syncing code and they don't break the build so it's ok if they get a little out of sync.

All 4 comments

I have created a draft PR (#969), if you like it I can continue working on it.

We still use tslint internally at Google, and it sounds like it'll be awhile before we can move off it. I'm not sure how much we gain from keeping the same tooling, but being able to move contributions between systems is nice. cc @rictic and @aomarks

If there are desirable lint passes in ESLint that aren't in TSLint then I say go for it. Lint errors won't block syncing code and they don't break the build so it's ok if they get a little out of sync.

Also @aomarks already merged ESLint in the Material Web Components project.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lastmjs picture lastmjs  路  5Comments

justinfagnani picture justinfagnani  路  4Comments

pjtatlow picture pjtatlow  路  3Comments

justinfagnani picture justinfagnani  路  3Comments

justinfagnani picture justinfagnani  路  3Comments