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: comments: ignores JSX

See original GitHub issue

Tell us about your environment

  • ESLint Version: ^6.1.0
  • Node Version: 12.9.0
  • npm Version: 6.9.0 What parser (default, Babel-ESLint, etc.) are you using?@typescript-eslint/parser”: ^2.0.0 Please show your full configuration:
Configuration
env:
  #https://medium.com/@jzarzoso/setting-eslint-on-meteor-for-react-development-10af658b44e2
  browser: true
  jest/globals: true
extends:
  - "eslint:recommended"
  - "plugin:@typescript-eslint/recommended"
  - "plugin:@typescript-eslint/eslint-recommended"
  - "hardcore-fp"
  - "plugin:jest/recommended"
  - "plugin:react/recommended"
  - "prettier"
  - "prettier/@typescript-eslint"
parser: "@typescript-eslint/parser"
parserOptions:
#  project: "./tsconfig.json"
  ecmaVersion: "2019"
  sourceType: module
plugins:
  - "@typescript-eslint/eslint-plugin"
  - jest
  - react
  - react-hooks
  - promise
overrides:
  - files:
      - "*.test.js"
      - "*.spec.js"
    rules:
      fp/no-unused-expression: "off"
rules:
  "@typescript-eslint/camelcase": off
  "@typescript-eslint/explicit-function-return-type":
    - error
    - allowExpressions: true
  "@typescript-eslint/interface-name-prefix":
    - error
    - prefixWithI: always
  "@typescript-eslint/no-use-before-define": off
  arrow-body-style: "off"
  camelcase: off
  comma-dangle: "off"
  fp/no-mutating-methods:
    - error
    # Allow reassign Lodash methods
    - allowedObjects:
        - _
  fp/no-mutation:
    - error
    # Allow module.exports
    - commonjs: true
      allowThis: false
      # Allow assigning to window global
      exceptions:
        - object: window
#  fp/no-nil: "off"
  fp/no-unused-expression: "off"
  func-style: warn
  id-length:
    - warn
    - exceptions:
        - e
        - f
        - i
        - v
        - x
        - "y"
        - z
  id-match:
    - error
    - "^[a-zA-Z_]*$"
    - properties: true
  indent: off
  lines-around-comment:
    - warn
    - ignorePattern: /prettier-ignore/
  max-len:
    - warn
    - code: 90
      comments: 120
      tabWidth: 2
      ignorePattern: "import"
      ignoreUrls: true
  max-params:
    - error
    - 6
  multiline-ternary: "off"
  new-cap: off
  no-inline-comments: "off"
  no-magic-numbers:
    - error
    - ignore:
        - 0
        - 1
  no-multi-spaces: "off"
  no-return-await: off
  no-param-reassign:
    - error
    - props: true
  no-nested-ternary: "off"
  no-shadow:
    - error
    - builtinGlobals: true
  no-warning-comments: warn
  no-undef: error
  no-unneeded-ternary: "off"
  no-unused-vars: warn
  no-use-before-define: "off"
  object-curly-newline: "off"
  one-var: off
  operator-linebreak:
    - error
    - before
    - overrides:
        =: ignore
  padding-line-between-statements: "off"
  radix: "off"
  react/no-string-refs:
    - error
    - noTemplateLiterals: true
  react-hooks/rules-of-hooks: error
  react-hooks/exhaustive-deps: warn
  react/display-name: "off"
  react/prop-types: "off"
  semi: warn
settings: {}

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

export function ScoringResultsItem() {
  return (
    <List.Item>
      <Checkbox checked={state.checked}>
        <Avatar src={bankDatum.logoURL} />
        {/* Some really really really really really really really really really long comment */}
        <a href={bankDatum.PAURL} target="_blank">
          {bankDatum.name}
        </a>
      </Checkbox>
    </List.Item>
  );
}

eslint foo.js

What did you expect to happen? no warnings logged

What actually happened? Please include the actual, raw output from ESLint. 6:1 warning This line has a length of 96. Maximum allowed is 90 max-len

Are you willing to submit a pull request to fix this bug? nope

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
btmillscommented, Nov 1, 2019

👍 I agree that this can be a semver-minor change, and that generally speaking we should consider the curlies part of the comment boundary in JSX. Should we also require that the curlies contain only a comment? For example, I would think the first case below should be valid but not the second:

<div>
    {/* this long comment should not violate max-len ignoring comments */}
    {42 /* this long comment that contains code inside the curlies should be invalid */}
</div>
1reaction
kaicataldocommented, Nov 1, 2019

I am championing this as a semver-minor bug fix to the default behavior (citing the precedence set here).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maxlength does not work React Js - Stack Overflow
The only way around this is to check the length of the value in the callback, and truncate it. Example class App extends...
Read more >
max-len - ESLint - Pluggable JavaScript Linter
"ignorePattern" ignores lines matching a regular expression; can only match a single line and need to be double escaped when written in YAML...
Read more >
How To Use and Disable ESLint Max-Len (Line Length Rule)
3 ESLint Max-Len Ignore Comments, URLs, Strings, and Template Literals. 4 ESLint Ignore Line Length for One or Many Lines.
Read more >
Options - Prettier
Use single quotes instead of double quotes. Notes: JSX quotes ignore this option – see jsx-single-quote. If the number of quotes outweighs the...
Read more >
vue/max-len
code ... enforces a maximum line length. · template ... · tabWidth ... · comments ... · ignorePattern ... · ignoreComments ... if...
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