question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

array-element-newline - inline objects inside array

See original GitHub issue

Tell us about your environment Node.js, ES6

  • **ESLint Version:**v4.19.1
  • **Node Version:**v9.6.1
  • **npm Version:**5.8.0

What parser (default, Babel-ESLint, etc.) are you using? Default Please show your full configuration: You can find full code of my configuration in repository: https://github.com/igolia/eslint-config-igolia

Configuration
'use strict';

const error = 'error';
const always = 'always';
const never = 'never';
const off = 'off';

module.exports = {
  env: {
    node: true,
    es6: true
  },
  parserOptions: { ecmaVersion: 8 },
  rules: {
    /**
     * Possible Errors
     */
    'for-direction': error,
    'getter-return': [error, { allowImplicit: true }],
    'no-await-in-loop': error,
    'no-compare-neg-zero': error,
    'no-cond-assign': [error, always],
    'no-console': error,
    'no-constant-condition': [error, { checkLoops: false }],
    'no-control-regex': error,
    'no-debugger': error,
    'no-dupe-args': error,
    'no-dupe-keys': error,
    'no-duplicate-case': error,
    'no-empty': error,
    'no-empty-character-class': error,
    'no-ex-assign': error,
    'no-extra-boolean-cast': error,
    'no-extra-parens': error,
    'no-extra-semi': error,
    'no-func-assign': error,
    'no-inner-declarations': error,
    'no-invalid-regexp': error,
    'no-irregular-whitespace': error,
    'no-obj-calls': error,
    'no-prototype-builtins': error,
    'no-regex-spaces': error,
    'no-sparse-arrays': error,
    'no-template-curly-in-string': error,
    'no-unexpected-multiline': error,
    'no-unreachable': error,
    'no-unsafe-finally': error,
    'no-unsafe-negation': error,
    'use-isnan': error,
    'valid-jsdoc': [
      error,
      {
        prefer: {
          arg: 'param',
          argument: 'param',
          class: 'class',
          return: 'returns',
          virtual: 'abstract'
        },
        preferType: {
          Boolean: 'Boolean',
          Number: 'Number',
          function: 'Function',
          object: 'Object',
          String: 'String',
          int: 'Number',
          array: 'Array'
        },
        requireParamDescription: false,
        requireReturnType: true,
        requireReturn: true,
        requireReturnDescription: false
      }
    ],
    'valid-typeof': error,

    /**
     * Best Practices
     */
    'accessor-pairs': off,
    'array-callback-return': [error, { allowImplicit: true }],
    'block-scoped-var': error,
    'class-methods-use-this': error,
    complexity: error,
    'consistent-return': off,
    curly: error,
    'default-case': error,
    'dot-location': [error, 'property'],
    'dot-notation': error,
    eqeqeq: [error, always],
    'guard-for-in': error,
    'no-alert': error,
    'no-caller': error,
    'no-case-declarations': error,
    'no-div-regex': error,
    'no-else-return': off,
    'no-empty-function': error,
    'no-empty-pattern': error,
    'no-eq-null': error,
    'no-eval': error,
    'no-extend-native': error,
    'no-extra-bind': error,
    'no-extra-label': error,
    'no-fallthrough': error,
    'no-floating-decimal': error,
    'no-global-assign': error,
    'no-implicit-coercion': error,
    'no-implicit-globals': error,
    'no-implied-eval': error,
    'no-invalid-this': error,
    'no-iterator': error,
    'no-labels': error,
    'no-lone-blocks': error,
    'no-loop-func': error,
    'no-magic-numbers': [
      error,
      {
        ignore: [1, 2, 3],
        ignoreArrayIndexes: true
      }
    ],
    'no-multi-spaces': error,
    'no-multi-str': error,
    'no-new': error,
    'no-new-func': error,
    'no-new-wrappers': error,
    'no-octal': error,
    'no-octal-escape': error,
    'no-param-reassign': error,
    'no-redeclare': error,
    'no-restricted-properties': [
      error,
      {
        object: 'require',
        message: 'Please call require() directly.'
      }
    ],
    'no-return-assign': [error, always],
    'no-return-await': error,
    'no-script-url': off,
    'no-self-assign': error,
    'no-self-compare': error,
    'no-sequences': error,
    'no-throw-literal': error,
    'no-unmodified-loop-condition': error,
    'no-unused-expressions': error,
    'no-unused-labels': error,
    'no-useless-call': error,
    'no-useless-concat': error,
    'no-useless-escape': error,
    'no-useless-return': error,
    'no-void': error,
    'no-warning-comments': off,
    'no-with': error,
    'prefer-promise-reject-errors': [error, { allowEmptyReject: true }],
    radix: [error, 'as-needed'],
    'require-await': error,
    'vars-on-top': error,
    'wrap-iife': [error, 'any'],
    yoda: error,

    /**
     * Strict Mode
     */
    strict: [error, 'global'],

    /**
     * Variables
     */
    'init-declarations': off,
    'no-catch-shadow': error,
    'no-delete-var': error,
    'no-label-var': error,
    'no-restricted-globals': off,
    'no-shadow': [
      error,
      {
        builtinGlobals: false,
        hoist: 'functions'
      }
    ],
    'no-shadow-restricted-names': error,
    'no-undef': error,
    'no-undef-init': error,
    'no-undefined': off,
    'no-unused-vars': error,
    'no-use-before-define': error,

    /**
     * Node.js and CommonJS
     */
    'callback-return': error,
    'global-require': error,
    'handle-callback-err': error,
    'no-buffer-constructor': error,
    'no-mixed-requires': error,
    'no-new-require': error,
    'no-path-concat': error,
    'no-process-env': error,
    'no-process-exit': error,
    'no-restricted-modules': off,
    'no-sync': error,

    /**
     * Stylistic Issues
     */
    'array-bracket-newline': [
      error,
      { multiline: true }
    ],
    'array-bracket-spacing': [error, never],
    'array-element-newline': [
      error,
      { multiline: true }
    ],
    'block-spacing': error,
    'brace-style': error,
    'camelcase': error,
    'capitalized-comments': [error, always],
    'comma-dangle': [error, never],
    'comma-spacing': [
      error,
      { before: false, after: true }
    ],
    'comma-style': [error, 'last'],
    'computed-property-spacing': [error, never],
    'consistent-this': [error, 'that'],
    'eol-last': [error, always],
    'func-call-spacing': [error, never],
    'func-name-matching': error,
    'func-names': [error, always],
    'func-style': [error, 'declaration', { allowArrowFunctions: true }],
    'function-paren-newline': [error, 'multiline'],
    'id-blacklist': off,
    'id-length': [
      error,
      {
        min: 3,
        max: 30,
        exceptions: ['i', 'j', 'k', 'l']
      }
    ],
    'id-match': [error, '^[a-z]+([A-Z][a-z]+)*$'],
    'implicit-arrow-linebreak': [error, 'beside'],
    indent: [
      error,
      2,
      {
        SwitchCase: 1,
        VariableDeclarator: 1,
        outerIIFEBody: 2,
        MemberExpression: 1,
        FunctionDeclaration: {
          body: 1,
          parameters: 1
        },
        FunctionExpression: {
          body: 1,
          parameters: 1
        },
        CallExpression: { arguments: 1 },
        ArrayExpression: 1,
        ObjectExpression: 1,
        ImportDeclaration: 1,
        flatTernaryExpressions: false
      }
    ],
    'jsx-quotes': [error, 'prefer-double'],
    'key-spacing': [
      error,
      {
        beforeColon: false,
        afterColon: true,
        mode: 'strict'
      }
    ],
    'keyword-spacing': [error, { before: true, after: true }],
    'line-comment-position': [error, { position: 'above', applyDefaultIgnorePatterns: true }],
    'linebreak-style': [error, 'unix'],
    'lines-around-comment': [
      error,
      {
        beforeBlockComment: true,
        allowBlockStart: true,
        allowBlockEnd: true,
        allowClassStart: true,
        beforeLineComment: true,
        allowClassEnd: true,
        allowObjectStart: true,
        allowObjectEnd: true,
        allowArrayStart: true,
        allowArrayEnd: true,
        applyDefaultIgnorePatterns: true
      }
    ],
    'lines-between-class-members': [error, always, { exceptAfterSingleLine: true }],
    'max-depth': off,
    'max-len': [error, { code: 120, tabWidth: 4, comments: 80 }],
    'max-lines': off,
    'max-nested-callbacks': [error, 3],
    'max-params': off,
    'max-statements': off,
    'max-statements-per-line': [error, { max: 1 }],
    'multiline-comment-style': [error, 'starred-block'],
    'multiline-ternary': [error, never],
    'new-cap': [error, { newIsCap: true, capIsNew: true }],
    'new-parens': error,
    'newline-per-chained-call': [error, { ignoreChainWithDepth: 2 }],
    'no-array-constructor': error,
    'no-bitwise': off,
    'no-continue': off,
    'no-inline-comments': error,
    'no-lonely-if': error,
    'no-mixed-operators': error,
    'no-mixed-spaces-and-tabs': error,
    'no-multi-assign': off,
    'no-multiple-empty-lines': [error, { max: 1, maxEOF: 1, maxBOF: 0 }],
    'no-negated-condition': error,
    'no-nested-ternary': error,
    'no-new-object': error,
    'no-plusplus': off,
    'no-restricted-syntax': off,
    'no-tabs': error,
    'no-ternary': off,
    'no-trailing-spaces': error,
    'no-underscore-dangle': [error, { allowAfterThis: true, allowAfterSuper: true, enforceInMethodNames: true }],
    'no-unneeded-ternary': error,
    'no-whitespace-before-property': error,
    'nonblock-statement-body-position': off,
    'object-curly-newline': [error, { multiline: true }],
    'object-curly-spacing': [error, always],
    'object-property-newline': off,
    'one-var': [error, never],
    'one-var-declaration-per-line': [error, always],
    'operator-assignment': [error, always],
    'operator-linebreak': [error, 'before'],
    'padded-blocks': [error, never],
    'padding-line-between-statements': [
      error,
      { blankLine: always, prev: 'directive', next: '*' },
      { blankLine: 'any', prev: 'directive', next: 'directive' },
      { blankLine: always, prev: ['const', 'let', 'var'], next: '*' },
      { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
      { blankLine: 'always', prev: '*', next: 'return' }
    ],

    quotes: [error, 'single'],
    semi: [error, always]
  }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const d = {
  'padding-line-between-statements': [
      error,
      { blankLine: always, prev: 'directive', next: '*' },
      { blankLine: 'any', prev: 'directive', next: 'directive' },
      { blankLine: always, prev: ['const', 'let', 'var'], next: '*' },
      { blankLine: 'any', prev: ['const', 'let', 'var'], next: ['const', 'let', 'var'] },
      { blankLine: 'always', prev: '*', next: 'return' }
    ]
};

What did you expect to happen? Expected that this array will not show error. What actually happened? Please include the actual, raw output from ESLint. I was looking for a similar issue in eslint/esling repository, but I did not find it. This array show me error, that after comma should not be new line.

Error image:

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, May 3, 2018

Hi @vuchastyi, thanks for the issue.

The ESLint team (of which ljharb is not a member, though he is a valued contributor) would be happy to review a proposal for enhancing a rule with a new option.

In order to make this easier, we prefer to have proposals laid out according to this template so we know exactly what users are looking for.

My suggestion would be to do the following, in order to prepare a proposal we could evaluate:

  1. Check out similar rules, like array-bracket-newline or object-property-newline, to see if something like the “consistent” option in those rules is what you want here.
  2. Once you’ve taken a look at those, edit the initial post of this issue (or create a new one if you like) to follow the template I linked above. Make sure to write a few examples of code that would be affected by the new option (either code that currently violates the rule that no longer would, or code that currently does not violate the rule that would violate it with the new option).

Once you’ve done that and know exactly what you’re looking for, we can evaluate the proposal.

Let me know if you have any questions 😄 Thanks!

0reactions
ghostcommented, May 4, 2018

@platinumazure, okey. I will create new issue-feature proposal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

array-element-newline - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
toml/array-element-newline | eslint-plugin-toml
Rule Details. This rule enforces line breaks between array elements. 1. 2.
Read more >
vue/array-element-newline - eslint-plugin-vue
vue/array-element-newline #. Enforce line breaks after each array element in <template>. ❗ This rule has not been released yet.
Read more >
Javascript: Create object array with functions directly inline
This objects contain a couple label/function. When I define an array into a scope and pass his content to element attribute it works,...
Read more >
disallow unquoted reserved words as property names in ...
no-reserved-keys: disallow unquoted reserved words as property names in object literals. (removed) This rule was removed in ESLint v1.0 and replaced by the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found