Skip to content
Permalink
Browse files

fix(eslint-plugin): [no-unnecessary-type-assertion] correct fixer for…

… vue files (#2680)
  • Loading branch information
thomasmichaelwallace committed Oct 18, 2020
1 parent c505863 commit 55111afd7819d29d65da4f41cc6a129f34aaeb3e
@@ -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

0 comments on commit 55111af

Please sign in to comment.
You can’t perform that action at this time.