conflict when use class-style component syntax and airbnb eslint rule
See original GitHub issueVersion
3.0.0-beta.6
Reproduction link
Steps to reproduce
I create a project which select these options: TypeScript Progressive Web App (PWA) Support Router Vuex CSS Pre-processors(SCSS) Linter / Formatter(ESLint Airbnb config)(on save and fix on commit), use class-style component syntax, Babel alongside TypeScript for auto-detected polyfills, then install it with Yarn.
Then I add lifecycle methods(like created) which code like this:
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
@Component
export default class About extends Vue {
created() {
// do something
}
}
</script>
Then I run yarn serve(or lint), it occurred an error with eslint, it said: error: Expected ‘this’ to be used by class method ‘created’ (class-methods-use-this)
What is expected?
I think it will be OK
What is actually happening?
It just couldn’t pass the lint rule
Actually, it occurs when I use 3.0.0-beta.7, but I can’t select this version in issue helper.
BTW, add this in .eslintrc can ignore this lint rule:
"rules": {
"class-methods-use-this": 0
}
but I think this shouldn’t occur after I build the project with vue-cli.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top GitHub Comments
Also, for the DYI approach, I just modified my project’s
.eslintrc.js
as so:For those still wrestling with this: adding the following to
.eslintrc.js
appears to solve the issue. Could this be added as a default?