@incutonez/eslint-plugin
v1.1.4
Published
I wanted my braces in objects (and arrays) to be on the same line as each other and the brackets of an array, so I had to alter 2 ESLint properties [array-bracket-newline](https://eslint.org/docs/latest/rules/array-bracket-newline) and [array-element-newl
Downloads
42
Maintainers
Readme
Purpose
I wanted my braces in objects (and arrays) to be on the same line as each other and the brackets of an array, so I had to alter 2 ESLint properties array-bracket-newline and array-element-newline. This repo contains those overrides. See also this SO Question.
I basically ported the ESLint code from here and here to TypeScript, added a new property bracesSameLine
(which is a boolean), and modified the check
functions to use this property and determine how to format properly.
It will correct braces that are on a different line as the open/close brace/bracket, like this:
const invalid = {
someFunction: function() {
},
arr: [
{
thing: 1
},
{
one: 2
}
]
};
const valid = {
someFunction: function() {
},
arr: [{
thing: 1,
}, {
one: 2,
}],
};
Installation and Usage
npm i -D @incutonez/eslint-plugin
Then in your ESLint config file, add the following:
- In
plugins
, add@incutonez
- In
rules
, add:
"@incutonez/array-element-newline": [
"error",
{
"multiline": true,
"minItems": 5,
"bracesSameLine": true
}
],
"@incutonez/array-bracket-newline": [
"error",
{
"multiline": true,
"minItems": 5,
"bracesSameLine": true
}
],