Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

[ter-max-len] + ignoreStrings #349

Open
Ky6uk opened this issue Aug 22, 2018 · 1 comment
Open

[ter-max-len] + ignoreStrings #349

Ky6uk opened this issue Aug 22, 2018 · 1 comment

Comments

@Ky6uk
Copy link

Ky6uk commented Aug 22, 2018

ignoreStrings: true does match code below like a string and ignores length check

function (param1: string, param2: number, param3: InterfaceName["prop"]) {
//                                                ^^^^^^^^^^^^^^^^^^^^^
//                                                this part detected like a string
}
@jmlopez-rod
Copy link
Collaborator

That is correct and unfortunately that is what the ESlint docs say:

"ignoreStrings": true ignores lines that contain a double-quoted or single-quoted string

I'm surprised no one has said anything about lines like you mentioned (without typescript)

function foo(param1: string, param2: number, param3: InterfaceName["prop"]) {
  const bar = fnCall(param3['doNotIgnoreMe'], param4["a"], param4[`b`], param4['c']);
}

The function call should be split but instead it is being ignored if we have the ignoreStrings or the the ignoreTemplateLiterals options.

It almost seems as if we need more a bit more control over strings. I was going to suggest to allow ignoreStrings to take in an object with exceptions:

ignoreStrings: {
  exceptPropertyAccess: true,
}

I think this would cover the example above, but then people would have issues with

const a = someElement['with-some-super-random-loooooooooooonnnnnnnnnggggggg-key-that-they-want-to-be-able-to-ignore'];

but this would be fixed by doing:

const key = 'with-some-super-random-loooooooooooonnnnnnnnnggggggg-key-that-they-want-to-be-able-to-ignore';
const a = someElement[key];

I actually want something like this even if eslint does not cover it. Can you think of other case scenarios where we would want to create exceptions to the ignore rules?

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

No branches or pull requests

2 participants