-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#IC-489] migrate ts-lint to eslint for io-functions-public #49
Conversation
5bb1d65
to
fd96ded
Compare
eslint-plugin-prettierAuthor: Teddy Katz Description: Runs prettier as an eslint rule Homepage: https://github.com/prettier/eslint-plugin-prettier#readme
|
Created | over 1 year ago |
Last Updated | about 1 month ago |
License | MIT |
Maintainers | 4 |
Releases | 7 |
Direct Dependencies | @typescript-eslint/eslint-plugin , @typescript-eslint/parser , eslint , eslint-config-prettier , eslint-plugin-extra-rules , eslint-plugin-fp , eslint-plugin-functional , eslint-plugin-import , eslint-plugin-jsdoc , eslint-plugin-prefer-arrow , eslint-plugin-prettier , eslint-plugin-react , eslint-plugin-sonarjs and prettier |
README
PagoPA ESLint config
This package provide the following ESLint custom rules for Typescript projects.
recommendend
react
strong
This repository replace italia-tslint-rules after TSLint deprecation.
The following TSLint rules (included inside italia-tslint-rules
) are not supported for eslint at the moment and are missing in this package:
bool-param-default
max-union-size
no-accessor-field-mismatch
no-array-delete // Mitigated by no-delete
no-case-with-or
no-dead-store
no-duplicate-in-composite
no-empty-array
no-extra-semicolon // Mitigated by prettier
no-empty-destructuring // Mititgated by no-empty-pattern
no-gratuitous-expressions
no-hardcoded-credentials
no-ignored-initial-value // Mitigated by no-param-reassign, no-let
no-in-misuse
no-inferred-empty-object-type
no-invalid-await // Mititgated by await-thenable
no-invariant-return
no-misleading-array-reverse // Mitigated by immutable-data
no-misspelled-operator // Mitigated by prettier
no-nested-switch
no-nested-template-literals
no-statements-same-line // Mitigated by prettier
no-try-promise
no-tslint-disable-all
no-unconditional-jump
no-undefined-argument
no-unenclosed-multiline-block // Mitigated by prettier
no-unthrown-error
no-unused-array // Mitigated by no-unused-vars
no-useless-increment
no-useless-intersection
prefer-promise-shorthand
promise-must-complete
use-primitive-type
This list has been produced following these steps:
- Follow TSLint to ESLint migration guide on the project io-backend
- Running
npx tslint-to-eslint-config
that produces a list of TSLint rules not available for ESLint (77 rules at the moment) - Manually check each one for an alternative ESLint rules/plugins
- Verify each alternative ESLint rule/plugin on a testing file
Usage
Installation and Configuration
To use this package install as devDependecy inside any typescript project with
yarn install -D @pagopa/eslint-config
Create on the project an .eslintrc.js
file with the following content
module.exports = {
"extends": [
"@pagopa/eslint-config/strong",
],
"rules": {
// Any project level custom rule
}
}
Add inside the package.json
file a lint
and optionally a lint-autofix
script as:
"scripts": {
"lint": "eslint . -c .eslintrc.js --ext .ts,.tsx",
"lint-autofix": "eslint . -c .eslintrc.js --ext .ts,.tsx --fix",
...
}
Migration from TSLint
Remove from the package.json
every tslint reference:
tslint
italia-tslint-rules
Replace all the // tslint:disable-next-line
with the proper // eslint-disable-next-line
comment. If are present some // tslint:disable
replace it with /* eslint-disable */
at the top of the file.
If you need to disable ESLint for some files create .eslintignore
file with the list of folders or files that must be excluded from lint process. Copy the exclusion from tslint.json
linterOptions.exclude
Delete all tslint related files (es. tslint.json
).
Run yarn lint-autofix
to refactorize the code automatically with all the auto-fixable ESLint rules.
New dependencies added: @pagopa/eslint-config
and eslint-plugin-prettier
.
Example of PR titles that include pivotal stories:
- single story:
[#123456] my PR title
- multiple stories:
[#123456,#123457,#123458] my PR title
Generated by 🚫 dangerJS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small comments
ValidateProfileEmail/handler.ts
Outdated
@@ -80,16 +82,19 @@ const TokenQueryParamMiddleware = RequiredQueryParamMiddleware( | |||
TokenQueryParam | |||
); | |||
|
|||
// tslint:disable-next-line: cognitive-complexity | |||
// eslint-disable-next-line sonarjs/cognitive-complexity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this is not needed anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arcogabbo just try to remove it and check if linting works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Just try to check the comment leave by @gquadrati .
ValidateProfileEmail/handler.ts
Outdated
@@ -80,16 +82,19 @@ const TokenQueryParamMiddleware = RequiredQueryParamMiddleware( | |||
TokenQueryParam | |||
); | |||
|
|||
// tslint:disable-next-line: cognitive-complexity | |||
// eslint-disable-next-line sonarjs/cognitive-complexity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arcogabbo just try to remove it and check if linting works.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
List of Changes
Migrated project from tslint to eslint
Motivation and Context
Development purposes
How Has This Been Tested?
All tests run fine
Screenshots (if appropriate):
Types of changes
Checklist: