-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#IP-86] tslint to eslint migration #14
Conversation
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.
Just minor changes
Co-authored-by: Emanuele De Cupis <[email protected]>
Co-authored-by: Emanuele De Cupis <[email protected]>
eslint-plugin-prettierAuthor: Teddy Katz Description: Runs prettier as an eslint rule Homepage: https://github.com/prettier/eslint-plugin-prettier#readme
|
Created | 3 months ago |
Last Updated | about 16 hours ago |
License | MIT |
Maintainers | 5 |
Releases | 6 |
Direct Dependencies | @typescript-eslint/eslint-plugin , @typescript-eslint/eslint-plugin-tslint , @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-no-credentials , 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
Codecov Report
@@ Coverage Diff @@
## master #14 +/- ##
==========================================
- Coverage 87.97% 87.50% -0.48%
==========================================
Files 22 22
Lines 424 416 -8
Branches 42 43 +1
==========================================
- Hits 373 364 -9
- Misses 50 51 +1
Partials 1 1
Continue to review full report at Codecov.
|
@balanza I have fixed yarn.lock and merged master resolving conflicts. Check have passed. |
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.
I made requested changes
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 ok to me. Can you please resolve conflicts, so we can merge?
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 should be all ok. @gquadrati can you check that everything is compliant with your new changes?
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 apart of two minor changes
Co-authored-by: gquadrati <[email protected]>
Co-authored-by: gquadrati <[email protected]>
List of Changes
tslint.json
filepackage.json
.eslintignore
ignore file.eslintrc.js
configuration.eslintrc.js
to avoid a deep refactoring of working codeMotivation and Context
We want to migrate to eslint because tslint is deprecated.
How Has This Been Tested?
It has been tested by performing:
Types of changes
Checklist: