1.0.0 • Published 2 years ago

eslint-plugin-import-curly-newline v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

eslint-plugin-import-curly-newlines

import curly newlines

Installation

You'll first need to install ESLint:

npm i eslint --save-dev

Next, install eslint-plugin-import-curly-newlines:

npm install eslint-plugin-import-curly-newlines --save-dev

Usage

Add import-curly-newlines to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": ["import-curly-newlines"]
}

Then configure the rules you want to use under the rules section.

nametypedefaultdescription
countnumber3If it exceeds count, each attribute will be wrapped.
{
  "rules": {
    "import-curly-newlines/newlines": [
      "error",
      {
        "count": 4
      }
    ]
  }
}

valid

import A from 'C'
import * as A from 'C'
// count defalut 3
import {A, B} from 'C'
import {
  A as AA,
  B
} from 'C'
import A, {
  AA as AAA,
  B as BB,
  C,
} from 'D'
import {
  A as AA,
  B,
} from 'C'
import A, {
  AA as AAA,
  B as BB,
  C,
} from 'D'

invalid

// invalid
import {
  A as AA,B, C} from 'C'

// ||
// \/

// valid
import {
  A as AA,
  B,
  C
} from 'C'

// invalid
import {
  A as AA,B, 
  C,
} from 'C'

// ||
// \/

// valid, Commas will be preserved
import {
  A as AA,
  B,
  C,
} from 'C'