-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat(build): add eslint scripts and default configs #2572
Conversation
91dab0c
to
b56849a
Compare
Yay for starting with a smaller patch first 👍 ❤️ |
packages/eslint-config/.eslintrc.js
Outdated
'@typescript-eslint/prefer-interface': 'off', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/ban-types': 'error', |
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.
As discussed in #2492, our code base is violating ban-types
rule in many places. Let's disable this rule in this initial pull request to make the migration from tslint to eslint easier & faster.
f9d62b8
to
d17ee28
Compare
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.
This comment is still not addressed: #2572 (comment)
Would it help you @raymondfeng if I took a look at the differences between tslint
and your proposed config myself?
"eslint": "^5.14.1", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-eslint-plugin": "^2.0.1", | ||
"eslint-plugin-mocha": "^5.3.0", |
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 think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build
. Could you please try to remove them?
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 think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build. Could you please try to remove them?
☝️
@bajtos I'm busy with other PRs and will visit this one again soon. |
9c53e9b
to
0da00ea
Compare
@bajtos I have updated ESLint configuration to reflect existing tslint rules. |
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.
Looks mostly good, please address my minor comments below before landing.
I didn't test this new PR in practice, I am considering this PR as an initial version that will be incrementally improved in follow-up pull requests as needed.
"eslint": "^5.14.1", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-eslint-plugin": "^2.0.1", | ||
"eslint-plugin-mocha": "^5.3.0", |
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 think these new dependencies at root level should not be needed as long as we always use the eslint config bundled as part of @loopback/build. Could you please try to remove them?
☝️
sourceType: 'module', | ||
project: './tsconfig.json', | ||
ecmaFeatures: { | ||
ecmaVersion: 2017, |
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.
'@typescript-eslint/adjacent-overload-signatures': 'error', // tslint:adjacent-overload-signatures | ||
'@typescript-eslint/prefer-for-of': 'error', // tslint:prefer-for-of | ||
'@typescript-eslint/unified-signatures': 'error', // tslint:unified-signatures | ||
'@typescript-eslint/no-explicit-any': 'error', // tslint:no-explicit-any |
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.
At the moment, we are using no-any
rule, can you enable it too please? Or is @typescript-eslint/no-explicit-any
replacement for tslint:no-any
and it's just the comment that's wrong here?
'@typescript-eslint/await-thenable': 'error', // tslint:await-promise: [true, 'PromiseLike', 'RequestPromise'], | ||
|
||
// https://github.com/xjamundx/eslint-plugin-promise | ||
// tslint:no-floating-promises: [true, 'PromiseLike', 'RequestPromise'], |
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.
Hmm, no-floating-promise
is actually very useful! It detects situations where people forget to await
a promise.
Here is the tracking issue: typescript-eslint/typescript-eslint#464 and pull request in progress: typescript-eslint/typescript-eslint#495
Please rework the comment to point to those two links instead of https://github.com/xjamundx/eslint-plugin-promise.
I am ok to move forward with this PR even if no-floating-promises
is not supported yet.
packages/eslint-config/eslintrc.js
Outdated
}; | ||
|
||
/** | ||
* tslint rules from `@loopback/tslint-config` for comparison |
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.
Let's remove the commented out code (L115-EOF). For anybody reviewing this patch, here are links to GitHub view of those two files:
tslint.common.json
tslint.build.json
https://github.com/strongloop/loopback-next/blob/4b68ef850318e865074449f2892e4f616aebaa0c/packages/tslint-config/tslint.build.json#L9-L23
Phase 1 for #2492:
@loopback/eslint-config
lb-eslint
to@loopback/build
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated