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

Misleading documentation 10.8 #2206

Open
kagant15 opened this issue Apr 8, 2020 · 6 comments
Open

Misleading documentation 10.8 #2206

kagant15 opened this issue Apr 8, 2020 · 6 comments

Comments

@kagant15
Copy link

kagant15 commented Apr 8, 2020

The documentation for 10.8 references object-curly-newline however object-curly-newline does not catch this rule. Furthermore airbnb's set of rules also doesn't catch this rule.

See Example

The guidance is good, however the documentation leads you to believe the linter will catch you if you put imports on the same line, which it doesn't.

@kagant15
Copy link
Author

kagant15 commented Apr 8, 2020

#2205

@ljharb
Copy link
Collaborator

ljharb commented Apr 8, 2020

The eslint link should not give you any confidence that the linter will cover the entire guideline - you always have to keep the entire guide in your head, just in case.

'object-curly-newline': ['error', {
ObjectExpression: { minProperties: 4, multiline: true, consistent: true },
ObjectPattern: { minProperties: 4, multiline: true, consistent: true },
ImportDeclaration: { minProperties: 4, multiline: true, consistent: true },
ExportDeclaration: { minProperties: 4, multiline: true, consistent: true },
}],
should definitely be catching that example - it's defined to only kick in if you have 4 or more imported names.

@kagant15
Copy link
Author

kagant15 commented Apr 9, 2020

Unless I'm missing something I think this may be a bug. I just tested this out again with the following:

// -- constants.js
export const one = 'one';
export const two = 'two';
export const three = 'three';
export const four = 'four';
export const five = 'five';
// -- example.js
import {
  one, two, three, four, five,
} from './constants';

if (one && two && three && four && five) {
  console.log('done');
}
// -- .eslintrc
{
"extends": ["airbnb"]
}
// -- package.json
"devDependencies": {
  "eslint-config-airbnb": "^18.1.0"
}

eslint --print-config example.js


  "object-curly-newline": [
      "error",
      {
        "ObjectExpression": {
          "minProperties": 4,
          "multiline": true,
          "consistent": true
        },
        "ObjectPattern": {
          "minProperties": 4,
          "multiline": true,
          "consistent": true
        },
        "ImportDeclaration": {
          "minProperties": 4,
          "multiline": true,
          "consistent": true
        },
        "ExportDeclaration": {
          "minProperties": 4,
          "multiline": true,
          "consistent": true
        }
      }
    ],

eslint example.js

6:3 warning Unexpected console statement no-console

✖ 1 problem (0 errors, 1 warning)

@ljharb
Copy link
Collaborator

ljharb commented Apr 9, 2020

In that case, please file it on eslint itself.

@ljharb
Copy link
Collaborator

ljharb commented Apr 9, 2020

I think the "consistent" rule is satisfied if all of the properties are on the same line, even if the braces aren't. If you have a newline in the middle of the list, what happens?

@xiaoxiyao
Copy link

eslint/eslint#12018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@ljharb @kagant15 @xiaoxiyao and others