1.5.0 • Published 2 years ago

eslint-plugin-newline v1.5.0

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

eslint-plugin-newline

ESLint plugin to enforce newlines in ES6 object destructuring or import

Installation

You'll first need to install ESLint:

// Npm
npm i eslint -D
// Yarn
yarn add eslint -D

Next, install eslint-plugin-newline:

// NPM
npm i eslint-plugin-newline -D
// YARN
yarn add eslint-plugin-newline -D

Demo

:thumbsdown: Before use

// import modules
import {example1, example2, example3, example4} from "example";
import {
  example1, example2, example3, example4
  } from "example";

// obejct destructuring
const {a, b, c, d, e, f,} = obj;
const {
    a, b, c, d, e, f,
} = obj;

:thumbsup: After use

// import modules
import {
  example1,
  example2,
  example3,
  example4,
} from 'example';

// obejct destructuring
const {
  name,
  age,
  options,
  example,
} = obj;

Usage

Add newline to the plugins section of your .eslintrc configuration file. Then configure the rules you want to use under the rules section.

{
    "plugins": [
        "newline"
    ],
    
    "rules": {
        "newline/object-property": ["error",{
            "minItems": 2,
            "tab": 2,
        }],
        "newline/import-module": ["error",{
            "minItems": 2,
            "tab": 2,
        }]
    }
}

Options

The rule accepts an option object with the following properties:

  • minItems number (minimum: 2) (default: 2) - Specifies the minimum number of attributes required for line breaks.
  • tab number (minimum: 1) (default: 2) - Specifies the number of spaces in front of the property after newline.
1.5.0

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago