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
Changes from all commits
f42fd2d
b259c00
8545085
4d9a63f
ee48d96
4cd6ae2
745039d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,12 +22,14 @@ import * as babel from 'babel-eslint'; | |
import { Linter, SourceCode } from 'eslint'; | ||
import { ParsingError } from './analyzer'; | ||
import * as VueJS from 'vue-eslint-parser'; | ||
import * as semver from 'semver'; | ||
|
||
// 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'; | ||
// next released version is 4.0.0, we need version which is above current 3.9.x and below 4.0.0 | ||
const TYPESCRIPT_MAXIMUM_VERSION = '3.10.0'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where does this version come from? I see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
export const PARSER_CONFIG_MODULE: Linter.ParserOptions = { | ||
tokens: true, | ||
|
@@ -122,13 +124,13 @@ export function resetReportedNewerTypeScriptVersion() { | |
|
||
// exported for testing | ||
export function checkTypeScriptVersionCompatibility(currentVersion: string) { | ||
if (currentVersion >= TYPESCRIPT_MAXIMUM_VERSION && !reportedNewerTypeScriptVersion) { | ||
if (semver.gt(currentVersion, TYPESCRIPT_MAXIMUM_VERSION) && !reportedNewerTypeScriptVersion) { | ||
reportedNewerTypeScriptVersion = true; | ||
console.log( | ||
`WARN You are using version of TypeScript ${currentVersion} which is not officially supported; ` + | ||
`supported versions >=${TYPESCRIPT_MINIMUM_VERSION} <${TYPESCRIPT_MAXIMUM_VERSION}`, | ||
); | ||
} else if (currentVersion < TYPESCRIPT_MINIMUM_VERSION) { | ||
} else if (semver.lt(currentVersion, TYPESCRIPT_MINIMUM_VERSION)) { | ||
throw { | ||
message: `You are using version of TypeScript ${currentVersion} which is not supported; supported versions >=${TYPESCRIPT_MINIMUM_VERSION}`, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,15 +36,15 @@ export const rule: Rule.RuleModule = { | |
|
||
create(context: Rule.RuleContext) { | ||
return { | ||
'TSUnionType, TSIntersectionType': function (node: estree.Node) { | ||
'TSUnionType, TSIntersectionType'(node: estree.Node) { | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. why did it compile before? without There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think some types are out of sync between TSESTree and estree |
||
const nodesWithGivenType = groupedTypes.get(nodeValue); | ||
const nodeType = typescriptType as TSESTree.Node; | ||
if (!nodesWithGivenType) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think this is minor improvement, let's keep it here |
||
}; | ||
}, | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ export const rule: Rule.RuleModule = { | |
const secondaryMessages = []; | ||
|
||
for (let i = begin; i < end; i++) { | ||
const prop = properties[i]; | ||
const prop = properties[i] as estree.Property; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and here, what about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here it is guarded by condition on line 70 |
||
if (prop.shorthand) { | ||
secondaryNodes.push(prop); | ||
secondaryMessages.push(`Move to ${positionMessage}`); | ||
|
@@ -70,7 +70,9 @@ export const rule: Rule.RuleModule = { | |
if (objectExpressionProperties.some(p => p.type !== 'Property')) { | ||
return; | ||
} | ||
const isShorthandPropertyList = objectExpressionProperties.map(p => p.shorthand); | ||
const isShorthandPropertyList = objectExpressionProperties.map( | ||
p => (p as estree.Property).shorthand, | ||
); | ||
const shorthandPropertiesNumber = isShorthandPropertyList.filter(b => b).length; | ||
|
||
const numberOfShorthandAtBeginning = getNumberOfTrueAtBeginning(isShorthandPropertyList); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,18 +35,6 @@ const placeHolderFilePath = path.resolve(`${__dirname}/fixtures/rule-tester-proj | |
* It will also assert that no issues is raised when there are no type information. | ||
*/ | ||
class RuleTesterTs extends RuleTester { | ||
ruleTesterNoTsConfig = new RuleTester({ | ||
parser, | ||
parserOptions: { | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
ecmaFeatures: { | ||
jsx: true, | ||
globalReturn: true, | ||
}, | ||
}, | ||
}); | ||
|
||
constructor(public expectNoIssuesWithoutTypes = true) { | ||
super({ | ||
parser, | ||
|
@@ -62,23 +50,14 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @saberduck not handled |
||
valid: tests.invalid, | ||
invalid: [], | ||
}); | ||
} | ||
|
||
tests.valid.forEach(test => { | ||
const setFilename = test => { | ||
if (!test.filename) { | ||
test.filename = placeHolderFilePath; | ||
} | ||
}); | ||
tests.invalid.forEach(test => { | ||
if (!test.filename) { | ||
test.filename = placeHolderFilePath; | ||
} | ||
}); | ||
}; | ||
|
||
tests.valid.forEach(setFilename); | ||
tests.invalid.forEach(setFilename); | ||
|
||
super.run(name, rule, tests); | ||
} | ||
|
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