Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add object-curly-newline rule #83

Merged
merged 6 commits into from Nov 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 25 additions & 2 deletions index.js
Expand Up @@ -204,7 +204,7 @@
radix: 'error',

// Disabled for now as it causes too much churn
// TODO: Enable it in the future when I have time to deal with

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'

Check warning on line 207 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable it in the future when I...'
// the churn and the rule is stable and has an autofixer.
// Still doesn't have a fixer as of ESLint 7.24.0.
// 'require-unicode-regexp': 'error',
Expand Down Expand Up @@ -366,12 +366,12 @@
'always',
{
// Workaround to allow class fields to not have lines between them.
// TODO: Get ESLint to add an option to ignore class fields.

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'

Check warning on line 369 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Get ESLint to add an option to...'
exceptAfterSingleLine: true,
},
],

// TODO: Enable this again when targeting Node.js 16.

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'

Check warning on line 374 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable this again when targeting...'
// 'logical-assignment-operators': [
// 'error',
// 'always',
Expand Down Expand Up @@ -420,8 +420,31 @@
'error',
'never',
],
// Disabled because of https://github.com/xojs/eslint-config-xo/issues/27
// 'object-property-newline': 'error',
'object-curly-newline': [
'error',
{
ObjectExpression: {
multiline: true,
minProperties: 2,
consistent: true,
},
ObjectPattern: {
multiline: true,
minProperties: 4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning?

Copy link
Contributor Author

@Talent30 Talent30 Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for asking! Upon reflection, I believe this might not be a good idea.

let {
g, h
} = obj;

The above format isn't very good IMO.

I am leaning towards to set this option as never now until the community enhance the object-property-newline rule or add destructuring-property-newline.

Happy to hear your thoughts :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add object-property-newline as well we can achieve the following result

Incorrect

let a = {foo: 1
};
let b = {
    foo: 1};
let c = {foo: 1, bar: 2
};

Object.assign(stream, {isTTY: true, columns, rows});

Correct

Object.assign(stream, {
    isTTY: true,
    columns,
    rows
});


let a = {foo: 1};
let b = {foo: 1};
let c = {
    foo: 1,
    bar: 2
};

consistent: true,
},
ImportDeclaration: {
multiline: true,
minProperties: 4,
consistent: true,
},
ExportDeclaration: {
multiline: true,
minProperties: 2,
Talent30 marked this conversation as resolved.
Show resolved Hide resolved
consistent: true,
},
},
],
'one-var': [
'error',
'never',
Expand Down Expand Up @@ -594,7 +617,7 @@
{
// `array` is disabled because it forces destructuring on
// stupid stuff like `foo.bar = process.argv[2];`
// TODO: Open ESLint issue about this

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'

Check warning on line 620 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Open ESLint issue about this'
VariableDeclarator: {
array: false,
object: true,
Expand All @@ -613,7 +636,7 @@
],
'prefer-numeric-literals': 'error',

// TODO: Enable when targeting Node.js 16.

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 12

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 16

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'

Check warning on line 639 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 14

Unexpected 'todo' comment: 'TODO: Enable when targeting Node.js 16.'
// 'prefer-object-has-own': 'error',

'prefer-rest-params': 'error',
Expand Down