-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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(typescript-estree)!: throw error on file not in project when project
set
#760
feat(typescript-estree)!: throw error on file not in project when project
set
#760
Conversation
project
set
Codecov Report
@@ Coverage Diff @@
## master #760 +/- ##
=========================================
- Coverage 94.26% 94.2% -0.06%
=========================================
Files 112 112
Lines 4793 4801 +8
Branches 1333 1334 +1
=========================================
+ Hits 4518 4523 +5
- Misses 158 159 +1
- Partials 117 119 +2
|
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.
thanks for doing this!
we probably need to test this with a vue project, just so we can see how this interacts with vue-eslint-parser
.
code itself looks good for me.
project
setproject
set
@bradzacher I've addressed your comments and synced with master. I haven't had a chance to try with vue yet, but I will as soon as I can (tomorrow or this weekend). |
Edit: Couldn't help myself from looking more.
parserOptions: {
parser: '@typescript-eslint/parser',
project: `${__dirname}/tsconfig.json`,
extraFileExtensions: [".vue"]
}
My mistake earlier was forgetting the |
Just to confirm - did you try that on a SFC (Single File Component)? (eg below) Based on #404 I wasn't sure if it'd work. Just for sanity can you add a test like this, just so we can make sure that we don't break support again. // .eslint.js
module.exports = {
parser: 'vue-eslint-parser',
parserOptions: {
"parser": '@typescript-eslint/parser',
"project": `${__dirname}/tsconfig.json`,
extraFileExtensions: ['.vue'],
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/no-implicit-any': 'error',
},
}; <!-- Hello.vue -->
<template>
<div>
<div>
<!-- !!!!! expected error !!!!! -->
Hello {{ (name as any) }}{{exclamationMarks}}
</div>
<button @click="decrement">-</button>
<button @click="increment">+</button>
</div>
</template>
<script lang="ts">
import Vue from "vue";
export default Vue.extend({
props: ['name', 'initialEnthusiasm'],
data() {
return {
enthusiasm: this.initialEnthusiasm,
}
},
methods: {
increment() { this.enthusiasm++; },
decrement() {
if (this.enthusiasm > 1) {
this.enthusiasm--;
}
},
},
computed: {
exclamationMarks(): any { // !!!!! expected error !!!!!
return Array(this.enthusiasm + 1).join('!');
}
}
});
</script> |
Yep, I can lint that file fine (assuming you meant Is the best way to add that test via another integration test with docker? |
Awesome, it's good that it works!
That's a good question for @JamesHenry - I don't know that test harness at all.
I didn't know about that function ... |
I'll add the integration test in a follow up, thanks again @uniqueiniquity! |
BREAKING CHANGE
Currently, when using
@typescript-eslint/parser
with theproject
option, there is no connection between the set of files as defined by thetsconfig.json
file(s) you provide and the files that you're actually linting. It turns out that if you lint a file not in that set, the process of building enough context to drive semantic rules incurs a significant performance hit.Here, we introduce an error when such a file is linted when the
project
setting is provided. This will help users avoid incurring this performance hit, while explicitly alerting them of what issue is occurring (rather than simply not running semantic lint rules on such files). Note that this error matches TSLint's behavior in this scenario.Fixes #724