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
Upgrade ESLint to 7.5.0 and typescript-eslint to 3.7.1 #2038
Conversation
8178479
to
cf9a7ca
Compare
see #2041 |
c306b04
to
a2f2f21
Compare
@@ -90,7 +90,7 @@ function reportBadUsage( | |||
break; | |||
case 'ObjectPattern': | |||
node.properties.forEach(prop => { | |||
reportBadUsage(prop.value, buildMessage, context); | |||
reportBadUsage((prop as estree.AssignmentProperty).value, buildMessage, context); |
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.
so if prop
is RestElement
we will pass undefined
as first argument to reportBadUsage
. It will work as expected but I'm not sure such casting to estree.AssignmentProperty
is clear about this between-the-lines logic.
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 rewrote this to properly handle RestElement
case, it also improves the rule to detect patterns like const {x, ...eval} = foo()
@@ -46,6 +46,8 @@ export const rule: Rule.RuleModule = { | |||
Program: (node: estree.Node) => checkStatements((node as estree.Program).body, context), | |||
BlockStatement: (node: estree.Node) => | |||
checkStatements((node as estree.BlockStatement).body, context), | |||
TSModuleBlock: (node: estree.Node) => | |||
checkStatements(((node as unknown) as TSESTree.TSModuleBlock).body as Statement[], context), |
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.
in fact this is a fix for FN. Do you think it deserves a separate ticket in backlog?
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 this is minor improvement, let's keep it here
@@ -145,7 +147,7 @@ function raiseInlineAndIndentedIssue( | |||
}); | |||
} | |||
|
|||
function isNestingStatement(node: estree.Node): node is NestingStatement { | |||
function isNestingStatement(node: estree.Node | TSESTree.Node): node is NestingStatement { |
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 don't think this change is required
const sourceCode = context.getSourceCode(); | ||
const compositeType = (node as unknown) as | ||
| TSESTree.TSUnionType | ||
| TSESTree.TSIntersectionType; | ||
const groupedTypes: Map<string, Array<TSESTree.Node>> = new Map(); | ||
|
||
compositeType.types.forEach(typescriptType => { | ||
const nodeValue = sourceCode.getText(typescriptType as estree.Node); | ||
const nodeValue = sourceCode.getText((typescriptType as unknown) as estree.Node); |
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.
why did it compile before? without as unknown
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.
something has changed in the type definitions that they don't overlap anymore, I didn't dig deeper
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.
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 some types are out of sync between TSESTree and estree
@@ -91,7 +91,7 @@ function containsShellOption(otherArguments: Argument[]) { | |||
return otherArguments.some( | |||
arg => | |||
arg.type === 'ObjectExpression' && | |||
arg.properties.some( | |||
(arg.properties as estree.Property[]).some( |
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.
what will happen to SpreadElement
property?
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 fixed the rule to handle SpreadElement
const TYPESCRIPT_MINIMUM_VERSION = '3.2.1'; | ||
const TYPESCRIPT_MAXIMUM_VERSION = '3.8.0'; | ||
const TYPESCRIPT_MINIMUM_VERSION = '3.3.1'; | ||
const TYPESCRIPT_MAXIMUM_VERSION = '3.10.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.
where does this version come from? I see <4.0.0
for typescript-eslint
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.
} | ||
|
||
@Test | ||
public void test_new_typescript() throws Exception { | ||
File dir = TestUtils.projectDir("tsproject-no-typescript"); | ||
TestUtils.npmInstall(dir, "typescript@3.8.0-dev.20191026", "--no-save"); | ||
String tsVersion = "4.0.0-beta"; |
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.
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.
hm, do you think it's an issue? I would keep as is
@@ -69,6 +69,7 @@ public void test() throws Exception { | |||
|
|||
String projectKey = "tsproject-test-ts-version-" + tsVersion; | |||
SonarScanner build = SonarScanner.create() | |||
.setDebugLogs(true) |
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.
do we want to keep this?
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.
no, removed
@@ -1,5 +1,5 @@ | |||
{ |
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.
do we have eslint issue for this change?
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.
@@ -0,0 +1,7 @@ | |||
{ |
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.
same here, it will be nice to list in the PR eslint issues causing these 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.
|
||
// this value is taken from typescript-estree | ||
// still we might consider extending this range | ||
// if everything which we need is working on older/newer versions | ||
const TYPESCRIPT_MINIMUM_VERSION = '3.2.1'; | ||
const TYPESCRIPT_MAXIMUM_VERSION = '3.8.0'; | ||
const TYPESCRIPT_MINIMUM_VERSION = '3.3.1'; |
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.
we should update documentation.md
9853780
to
aa09234
Compare
aa09234
to
4cd6ae2
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.
@@ -62,13 +62,6 @@ class RuleTesterTs extends RuleTester { | |||
invalid?: RuleTester.InvalidTestCase[]; | |||
}, | |||
): void { | |||
if (this.expectNoIssuesWithoutTypes) { | |||
this.ruleTesterNoTsConfig.run(`${name}[noTsConfig]`, rule, { |
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.
@saberduck not handled
a7e0d06
to
745039d
Compare
Kudos, SonarQube Quality Gate passed! |
Bump of dependencies
Changes in ruling are related to improvements in eslint
if
statements eslint/eslint#12947 for S121