Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Adds TypeScript linting #642

Merged
merged 4 commits into from
Jun 11, 2019
Merged

Adds TypeScript linting #642

merged 4 commits into from
Jun 11, 2019

Conversation

tinkertrain
Copy link
Collaborator

@tinkertrain tinkertrain commented Jun 5, 2019

Adds TypeScript linting

This updates some of the code quality tools used in HSDS, specifically adds support for linting TypeScript.

Issue: #616

Previously HSDS was using Create React App's ESLint configuration: https://www.npmjs.com/package/eslint-config-react-app

I removed this dependency and instead based our configuration off of it and https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb, the main reason is that the CRA config uses flow under the hood for .js files and a separate config (override) for .ts files.

It's a bit more manual work, but we shouldn't need to touch the rules often if at all (until we adopt Hooks 😈).

I tested that ESLint is working by running npm run lint (which was updated to run on both .js and .ts|.tsx files) and on VSCode.

VSCode recommended settings

The eslint configuration plus these vscode specific settings allows you to use the eslint and prettier automatic fixing when possible:

"eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    { "language": "typescript", "autoFix": true },
    { "language": "typescriptreact", "autoFix": true }
  ],
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false
  },
  "[javascriptreact]": {
    "editor.formatOnSave": false
  },
  "[typescript]": {
    "editor.formatOnSave": false
  },
  "[typescriptreact]": {
    "editor.formatOnSave": false
  },

@tinkertrain tinkertrain self-assigned this Jun 5, 2019
@netlify
Copy link

netlify bot commented Jun 5, 2019

Deploy preview for hsds-react ready!

Built with commit 4e5f1cd

https://deploy-preview-642--hsds-react.netlify.com

@coveralls
Copy link

coveralls commented Jun 5, 2019

Pull Request Test Coverage Report for Build 2249

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 2242: 0.0%
Covered Lines: 11179
Relevant Lines: 11179

💛 - Coveralls

@tinkertrain tinkertrain requested a review from ItsJonQ June 10, 2019 10:20
@ItsJonQ
Copy link
Contributor

ItsJonQ commented Jun 10, 2019

@tinkertrain This is awesome!! 😍

I was wondering what y'alls thoughts are on adding a project specific .vscode/settings.json file for the config Juan Pablo suggested:

{
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    { "language": "typescript", "autoFix": true },
    { "language": "typescriptreact", "autoFix": true }
  ],
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false
  },
  "[javascriptreact]": {
    "editor.formatOnSave": false
  },
  "[typescript]": {
    "editor.formatOnSave": false
  },
  "[typescriptreact]": {
    "editor.formatOnSave": false
  }
}

The ESLint stuff only kicked in for TS files for me after I added this.

Copy link
Collaborator

@plbabin plbabin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for taking care of this 🚀

I am in for the vscode config

Copy link
Contributor

@ItsJonQ ItsJonQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tinkertrain Amazing work! 🚀 🚢 from me!

Glad @plbabin is on board. If you could add the .vscode local settings, that would be awesome!

Copy link
Collaborator

@knicklabs knicklabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support these changes and adding the VS Code config.

@tinkertrain
Copy link
Collaborator Author

Cool! Thank you all for looking at this. I've added the vscode file 👍

@ItsJonQ ItsJonQ added the patch ☝️ To indicate patch version bumps label Jun 11, 2019
@ItsJonQ ItsJonQ merged commit cd04fa1 into master Jun 11, 2019
@ItsJonQ ItsJonQ removed the patch ☝️ To indicate patch version bumps label Jun 11, 2019
@plbabin plbabin deleted the tooling/eslint-updates branch April 27, 2020 14:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants