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.

max-len - ignoreStrings / ignoreTemplateLiterals too aggressive

See original GitHub issue
  • **ESLint Version: 3.16.1
  • **Node Version:6.6.0
  • **npm Version:3.10.3

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

babel-eslint

Please show your full configuration:

{
  "parser": "babel-eslint",
  "extends": [
    "airbnb"
  ],
  "plugins": [
    "no-unused-vars-rest"
  ],
  "env": {
    "browser": true,
    "jest": true
  },
  "globals": {
    "__DEV__": true,
    "__PROD__": true,
    "__DEBUG__": true,
    "__COVERAGE__": true,
    "__BASENAME__": true
  },
  "settings": {
    "import/resolver": {
      "webpack": {
        "config": "webpack/webpack.config.js"
      }
    }
  },
  "rules": {
    "arrow-parens": [2, "always"],
    'comma-dangle': ['error', {
      arrays: 'always-multiline',
      objects: 'always-multiline',
      imports: 'always-multiline',
      exports: 'always-multiline',
      functions: 'ignore',
    }],
    "import/no-extraneous-dependencies": [2, {"devDependencies": ["**/*.test.js", "**/*.stories.js"]}],
    "no-console": 2,
    "react/jsx-boolean-value": [2, "always"],
    "react/jsx-filename-extension": [2, {"extensions": [".js", ".jsx"]}]
  }
}

What did you do? Please include the actual source code causing the issue. Created line

const date = this.props.intl.formatDate(new Date(), { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', timeZone: 'UTC' });

which has about 180 signs.

What did you expect to happen?

Show error, as default setting is set to 100 signs. Yet no error.

What actually happened?

No error was shown, because “ignoreStrings”/“ignoreTemplateLiterals” is set to true. That’s fantastic settings, as partitioning template literals isn’t quite good code for me. But now this setting is too aggressive and ignores line like the one inserted before. There are strings, but I don’t think that’s enough not to parse this line.

Unfortunatelly I have no idea how to make it less aggressive, so that lines that contains ie. objects with string values could still be parsed. 😦

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
vitorbalcommented, Mar 8, 2017

Thank you for your issue!

I’m not very familiar with the ignoreStrings / ignoreTemplateLiterals implementation. My guess is that it looks for any Literal or TemplateLiteral nodes in the line and if found, disables the maxlen warning for that line. I wonder if it would make sense to fine-tune it to only disable the warning if the last token is a Literal or TemplateLiteral

0reactions
not-an-aardvarkcommented, Jul 11, 2017

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn’t get enough support from the team and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after a long time tend to never do it, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Use and Disable ESLint Max-Len (Line Length Rule)
Here I have "ignoreStrings": false configured. Now the lines with strings are also flagged as being too long.
Read more >
max-len - 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 >
How to disable eslint rule max line length for paragraph in ...
AFAIK, there is no way to apply eslint rules to the template, and specifically to one line in a template. I hope to...
Read more >
vue/max-len
This rule enforces a maximum line length to increase code readability and maintainability. This rule is the similar rule as core max-len rule ......
Read more >
@alasdair/eslint-plugin-max-len - npm
ignoreStrings : true ignores lines that contain a double-quoted or single-quoted string. ignoreTemplateLiterals: true ignores lines that ...
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