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.

"ignoreAccessorPattern" doesn't behave like the TSLint version

See original GitHub issue

My new ESLint config:

        "functional/immutable-data": ["error", {
            ignorePattern: ["^mutable"],
            ignoreAccessorPattern: ["**.mutable*.*", "**.current.*"],
        }],

My old TSLint config:

"no-object-mutation":
  [true, {"ignore-prefix": "mutable", "ignore-pattern": ["**.mutable*", "**.current"]}]

And here the sample code, where it behaves differently:

export class SomeClass {

    private mutableSomething?: string;

    mutate(): void {
        this.mutableSomething = "xx"; // Ignored in TSLint, now reported
    }
}

//

const somethingLikeReactUseRef = { current: "x" };

somethingLikeReactUseRef.current = "y"; // Ignored in TSLint, now reported

Am I doing something wrong?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
RebeccaStevenscommented, Jul 29, 2019

Yes,

This config should work for your original code (once the update is merged in):

"functional/immutable-data": ["error", {
  "ignoreAccessorPattern": ["**.mutable*", "**.current"],
}]

As only string are being modified in your code, property mutation doesn’t need to be checked. However, to allow for reassigning and property mutation use:

"functional/immutable-data": ["error", {
  "ignoreAccessorPattern": ["**.mutable*.**", "**.current.**"],
}]
0reactions
ulrichbcommented, Jul 29, 2019

Just updated. Works great! Many thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

microsoft/tslint-microsoft-contrib: A set of TSLint rules ... - GitHub
This is case-insensitive by default but ignores file extension. It can be configured to be case-insensitive or to allow names matching a regex....
Read more >
TSLint extension throwing errors in my Angular application ...
Disable/Uninstall TSLint from your Visual Studio Code. You can then, place a script in your package.json file as - "lint": "eslint -c .eslintrc....
Read more >
Documentation - What is a tsconfig.json - TypeScript
When input files are specified on the command line, tsconfig.json files are ignored. Examples. Example tsconfig.json files: Using the files property.
Read more >
Code Inspections in JavaScript and TypeScript - JetBrains
This topic lists all JetBrains Rider code inspections available in JavaScript and TypeScript. You can toggle specific inspections or change ...
Read more >
Microsoft Azure Security Code Analysis task customization guide
NOTE: Please make sure that the group policy does not disable the ... the build task will behave according to the selected value...
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