最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - "lines-between-class-members" ESLint Error When Declaring Class Properties - Stack Overflow

programmeradmin1浏览0评论

As I like the "lines-between-class-members" rule, I'd like to enforce spaces between my classes' functions, but in the same time I want the properties declarations packed at the beginning of my classes in the following format:

class Foo {
  a: number;
  b: number;
  c: string;
  d: string;

  constructor() {
    // constructor stuff
  }

  doSomething() {
    // do something
  }
}

Is there a way to ignore this rule specifically on types declarations?

As I like the "lines-between-class-members" rule, I'd like to enforce spaces between my classes' functions, but in the same time I want the properties declarations packed at the beginning of my classes in the following format:

class Foo {
  a: number;
  b: number;
  c: string;
  d: string;

  constructor() {
    // constructor stuff
  }

  doSomething() {
    // do something
  }
}

Is there a way to ignore this rule specifically on types declarations?

Share Improve this question edited Jun 24, 2020 at 11:05 GalAbra asked Jun 24, 2020 at 10:48 GalAbraGalAbra 5,1485 gold badges25 silver badges43 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 20

It seems like you'll have to do this

'lines-between-class-members': [
  'error',
  'always',
  { 'exceptAfterSingleLine': true },
]

Docs It will skips checks for empty lines after a single-line class member.

add the rule into the .eslintrc.js

lines-between-class-members: ["error", "never"]

also, this link will be more helpful: https://eslint.org/docs/rules/lines-between-class-members

Please add this hopefully it will work:

/* eslint-disable no-trailing-spaces */

发布评论

评论列表(0)

  1. 暂无评论