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.

Indendation rule bugged

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.3.0
  • Node Version: 8.2.1

What parser (default, Babel-ESLint, etc.) are you using? Default

Please show your full configuration:

Configuration
root: true
extends: eslint:recommended
parserOptions:
  ecmaVersion: 2017
  ecmaFeatures:
    impliedStrict: true
  sourceType: module
env:
  es6: true
  browser: true
  node: true
  mocha: true
  jasmine: true
globals:
  angular: false
  Raven: false
rules:
  linebreak-style:
    - error
    - unix
  max-len:
    - warn
    - code: 80
      tabWidth: 2
      ignoreComments: true
      ignoreUrls: true
      ignoreTemplateLiterals: true
      ignoreRegExpLiterals: true
  indent:
    - error
    - 2
    - SwitchCase: 1
      VariableDeclarator:
        let: 2
        const: 3
  semi:
    - error
    - always
  consistent-this:
    - error
    - self
    - $ctrl
  quotes:
    - error
    - single
    - allowTemplateLiterals: true
  quote-props:
    - error
    - as-needed
  curly:
    - error
    - all
  comma-dangle:
    - error
    - always-multiline
  new-cap:
    - error
    - newIsCap: true
      capIsNew: true
      properties: false
  camelcase:
    - error
    - properties: never
  array-bracket-spacing:
    - error
    - never
  arrow-spacing:
    - error
    - before: true
      after: true
  block-spacing:
    - error
    - always
  comma-spacing:
    - error
    - before: false
      after: true
  computed-property-spacing:
    - error
    - never
  generator-star-spacing:
    - error
    - before: true
      after: false
  key-spacing:
    - error
    - beforeColon: false
      afterColon: true
      mode: minimum
  keyword-spacing:
    - error
    - before: true
  semi-spacing:
    - error
    - before: false
      after: true
  space-in-parens:
    - error
    - never
  space-unary-ops:
    - error
    - words: true
      nonwords: false
  space-before-function-paren:
    - error
    - never
  space-before-blocks:
    - error
    - always
  yoda:
    - error
    - never
  wrap-iife:
    - error
    - outside
  eqeqeq:
    - error
    - always
  newline-per-chained-call:
    - error
    - ignoreChainWithDepth: 3
  one-var-declaration-per-line:
    - error
    - initializations
  brace-style:
    - error
    - stroustrup
  no-implicit-coercion:
    - error
    - boolean: false
  no-multiple-empty-lines:
    - error
    - max: 1
  no-unused-vars:
    - error
    - vars: all
      args: all
  eol-last: error
  dot-notation: error
  space-infix-ops: error
  no-with: error
  no-unreachable: error
  no-redeclare: error
  no-unexpected-multiline: error
  no-multi-spaces: error
  no-multi-str: error
  no-trailing-spaces: error
  no-mixed-spaces-and-tabs: error
  no-spaced-func: error
  no-whitespace-before-property: error
  no-lonely-if: error
  no-var: error
  no-console: warn

What did you do? Please include the actual source code causing the issue. I updated ESLint from 3.x to 4.x


/**
 * Module definition and dependencies
 */
angular.module('App.Portal.Welcome.Credentials', [])

/**
 * Config
 */
.config($stateProvider => {
  $stateProvider.state('welcome.credentials', {
    url: '/credentials',
    component: 'welcomeCredentialsRoute',
  });
})

/**
 * Route component
 */
.component('welcomeCredentialsRoute', {
  controller: 'WelcomeCredentialsCtrl',
  templateUrl: 'portal/welcome/steps/credentials.html',
  bindings: {
    token: '<',
    club: '<',
    user: '<',
  },
})

What did you expect to happen? For ESLint to leave my code untouched, as it’s properly indented.

What actually happened? Please include the actual, raw output from ESLint. ESLint indents it as follows:

/**
 * Module definition and dependencies
 */
angular.module('App.Portal.Welcome.Credentials', [])

/**
 * Config
 */
  .config($stateProvider => {
    $stateProvider.state('welcome.credentials', {
      url: '/credentials',
      component: 'welcomeCredentialsRoute',
    });
  })

/**
 * Route component
 */
  .component('welcomeCredentialsRoute', {
    controller: 'WelcomeCredentialsCtrl',
    templateUrl: 'portal/welcome/steps/credentials.html',
    bindings: {
      token: '<',
      club: '<',
      user: '<',
    },
  })

I don’t want the config and component blocks to be indented. 3.x didn’t use to do this, and I can’t seem to find a setting in the indent rule to turn this behaviour off. Please advise.

I’ve had to revert to 3.x to prevent ESLint from messing up all my files.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Jul 27, 2017

You can use MemberExpression: "off", or use the indent-legacy rule.

0reactions
adamreisnzcommented, Jul 27, 2017

Yeah I installed 4 again, but failed to restart Atom. It started erroring on the indentation again so I assumed it was using 4. After restart the ‘off’ setting works and it’s not touching the indentation, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

indent rule bug? · Issue #3832 · eslint/eslint - GitHub
With current logic, if a file is entirely indented the indent rule will pass which I don't think is intended. For example if...
Read more >
Prettier and eslint indents not working together - Stack Overflow
ESLint's indent rule and Prettier's indentation styles do not match - they're completely separate implementations and are two different ...
Read more >
indentation - \rule not aligned - TeX - LaTeX Stack Exchange
You're setting two blocks ( \rule s in this case) that form part of a single paragraph where the first line of a...
Read more >
Space Indentation Expected: Fix - Genuitec
If your Eclipse and CodeMix settings did not match, you will now be indenting your code with tabs instead of spaces, or vice...
Read more >
Importing 'indent' rule from ESLint configuration ... - YouTrack
The first example (Align when Multiline On) conflicts with ESLint's 'indent' rule, so when importing code style settings from a config that contains ......
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