Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul of ignore-prefix #137

Merged
merged 5 commits into from Jun 5, 2019
Merged

Overhaul of ignore-prefix #137

merged 5 commits into from Jun 5, 2019

Conversation

RebeccaStevens
Copy link
Collaborator

@RebeccaStevens RebeccaStevens commented May 14, 2019

Fixes #101, #114, #136

ignore-prefix has been re-implement.

In the new implementation, only the name is tested against. So for example, only foo would be tested against for the following code.

const foo = 1;

New rule options

  • ignore-suffix - Just like ignore-prefix but with suffix matching.
  • ignore-pattern - Allow specifying pattern(s) to match against.

Issue Fixes

#101

Allow array mutation on arrays that start with the name "mutable", regardless of how deep they are.

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

#114

ignore-pattern can essentially be used as ignore-exact.

{
  "no-expression-statement": [
    true,
    {
      "ignore-pattern": [
        "afterAll",
        "afterEach",
        "beforeAll",
        "beforeEach",
        "describe",
        "expect",
        "test",
        "wrapper"
      ]
    }
  ]
}

#136

Allow object mutation on objects called "defaultProps", regardless of how deep they are.

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

@RebeccaStevens
Copy link
Collaborator Author

A bit more testing is probably needed before merging this.

@ulrichb
Copy link

ulrichb commented May 31, 2019

Nice! This will fix two of my scenarios.

@jonaskello
Copy link
Owner

Looks good to me! I think there is a fair amount of tests included too.

@RebeccaStevens RebeccaStevens merged commit 86fb92e into master Jun 5, 2019
@RebeccaStevens
Copy link
Collaborator Author

I decide to go ahead and release this as is. Hopefully any bugs found from now on will be easy fixes.

@karol-majewski
Copy link

Thank you!

Just a side note: I believe the example should say:

-"no-object-mutation": [true, { "ignore-pattern": "**.defaultProps.*" }]
+"no-object-mutation": [true, { "ignore-pattern": "**.defaultProps*" }],

because there is no dot when you do MyComponent.defaultProps = { /* ... */ }. 😉

@RebeccaStevens RebeccaStevens deleted the feature/ignore-overhaul branch June 17, 2019 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Take this-access into account for ignore-prefix
4 participants