mirror of
https://github.com/openharmony/third_party_typescript_eslint.git
synced 2026-06-30 21:27:59 -04:00
fix(eslint-plugin): [no-unnecessary-type-assertion] correct fixer for vue files (#2680)
This commit is contained in:
committed by
GitHub
parent
3f20973e54
commit
ac55e5e0b8
@@ -241,12 +241,12 @@ export default util.createRule<Options, MessageIds>({
|
||||
fix(fixer) {
|
||||
return originalNode.kind === ts.SyntaxKind.TypeAssertionExpression
|
||||
? fixer.removeRange([
|
||||
originalNode.getStart(),
|
||||
originalNode.expression.getStart(),
|
||||
node.range[0],
|
||||
node.expression.range[0] - 1,
|
||||
])
|
||||
: fixer.removeRange([
|
||||
originalNode.expression.end,
|
||||
originalNode.end,
|
||||
node.expression.range[1] + 1,
|
||||
node.range[1],
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -19,5 +19,7 @@ module.exports = {
|
||||
],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
||||
'semi-spacing': 'error',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script lang="ts">
|
||||
/* https://github.com/typescript-eslint/typescript-eslint/issues/2591 */
|
||||
/* eslint-disable class-methods-use-this */
|
||||
export default class Utility {
|
||||
get a() {
|
||||
const list: Array<string> = [];
|
||||
return list;
|
||||
}
|
||||
|
||||
get b() {
|
||||
const a = this.a as Array<string>;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -80,6 +80,31 @@ export default Vue.extend({
|
||||
}
|
||||
});
|
||||
</script>
|
||||
",
|
||||
"usedDeprecatedRules": Array [],
|
||||
"warningCount": 0,
|
||||
},
|
||||
Object {
|
||||
"errorCount": 0,
|
||||
"filePath": "/usr/linked/Utility.vue",
|
||||
"fixableErrorCount": 0,
|
||||
"fixableWarningCount": 0,
|
||||
"messages": Array [],
|
||||
"output": "<script lang=\\"ts\\">
|
||||
/* https://github.com/typescript-eslint/typescript-eslint/issues/2591 */
|
||||
/* eslint-disable class-methods-use-this */
|
||||
export default class Utility {
|
||||
get a() {
|
||||
const list: Array<string> = [];
|
||||
return list;
|
||||
}
|
||||
|
||||
get b() {
|
||||
const a = this.a;
|
||||
return a;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
",
|
||||
"usedDeprecatedRules": Array [],
|
||||
"warningCount": 0,
|
||||
|
||||
@@ -23,7 +23,7 @@ npm install vuex@latest vue-property-decorator@latest
|
||||
|
||||
# Run the linting
|
||||
# (the "|| true" helps make sure that we run our tests on failed linting runs as well)
|
||||
npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.vue || true
|
||||
npx eslint --format json --output-file /usr/lint-output.json --config /usr/linked/.eslintrc.js /usr/linked/**/*.vue --fix-dry-run || true
|
||||
|
||||
# Run our assertions against the linting output
|
||||
npx jest /usr/test.js --snapshotResolver=/usr/utils/jest-snapshot-resolver.js
|
||||
|
||||
Reference in New Issue
Block a user