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

Refactor for better type-checking #5644

Merged
merged 1 commit into from Oct 26, 2021
Merged

Refactor for better type-checking #5644

merged 1 commit into from Oct 26, 2021

Conversation

ybiquitous
Copy link
Member

Which issue, if any, is this issue related to?

Is there anything in the PR that needs further explanation?

This change aims to improve type-checking and refactor tsconfig.json:

  • Add noFallthroughCasesInSwitch. This aims to prevent a fallthrough bug.
  • Add noUnusedParameters. This aims to improve readability. If you'd like to avoid the error, add a prefix _.
  • Remove noImplicitThis and alwaysStrict. These are enabled by strict: true.

See https://www.typescriptlang.org/tsconfig

This change aims to improve type-checking and refactor `tsconfig.json`:

- Add `noFallthroughCasesInSwitch`. This aims to prevent a *fallthrough* bug.
- Add `noUnusedParameters`. This aims to improve readability. If you'd like to avoid the error, add a prefix `_`.
- Remove `noImplicitThis` and `alwaysStrict`. These are enabled by `strict: true`.

See <https://www.typescriptlang.org/tsconfig>
@ybiquitous
Copy link
Member Author

I thought it is useful to enable also noUnusedLocals, but the option causes the following errors:

$ npm run lint:types
> stylelint@14.0.0 lint:types
> tsc

types/stylelint/type-test.ts(47,8): error TS6133: 'err' is declared but its value is never read.
types/stylelint/type-test.ts(48,8): error TS6133: 'output' is declared but its value is never read.
types/stylelint/type-test.ts(51,9): error TS6133: 'warnings' is declared but its value is never read.
types/stylelint/type-test.ts(55,7): error TS6133: 'formatter' is declared but its value is never read.
types/stylelint/type-test.ts(62,7): error TS6133: 'problemMessage' is declared but its value is never read.
types/stylelint/type-test.ts(63,7): error TS6133: 'problemFunc' is declared but its value is never read.

I could not find a good way to resolve the errors in types/stylelint/type-test.ts, so I gave up enabling the option. Any help is welcome. 😃

@hudochenkov
Copy link
Member

There is already ESLint rule enabled similar to noUnusedLocals. No need to show the same problem in two tools. Also during development is very annoying rule.

@ybiquitous
Copy link
Member Author

Ah, I forgot we are using the ESLint no-unused-vars rule. Surely, noUnusedLocals is unnecessary. 👍🏼

https://github.com/stylelint/eslint-config-stylelint/blob/80cd6392b4be512bd6e1381753b3fc4411d4c043/.eslintrc.js#L49-L54

@jeddy3 jeddy3 changed the title Update tsconfig for better type-checking Refactor for better type-checking Oct 25, 2021
Copy link
Member

@jeddy3 jeddy3 left a comment

Choose a reason for hiding this comment

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

Thanks!

@jeddy3 jeddy3 mentioned this pull request Oct 25, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants