Skip to content

conflict when use class-style component syntax and airbnb eslint rule #1203

Closed
@wzsayhi

Description

@wzsayhi

Version

3.0.0-beta.6

Reproduction link

https://github.com/BGPSekai/T.Vey-frontend/blob/d09c83f82def85ace3f2739982648ee2629b1bb0/src/views/About.vue

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions