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

Add filename ignore pattern for match-exports rule #14

Merged
merged 1 commit into from Apr 11, 2017

Conversation

avaly
Copy link
Contributor

@avaly avaly commented Jan 30, 2017

This adds an additional option to the match-exports rule: a filename ignore pattern.

If you prefer to use suffixes for your files (e.g. Foo.react.js for a React component file), you can use the following configuration:

"filenames/match-exported": [2, "", "\\.react"]

@coveralls
Copy link

coveralls commented Jan 30, 2017

Coverage Status

Coverage remained the same at 100.0% when pulling 478492c on avaly:match-exports-filename-ignore-pattern into 8bf352e on selaux:master.

@selaux
Copy link
Owner

selaux commented Feb 20, 2017

Does this work for you: https://github.com/mradionov/eslint-plugin-disable#file-paths?

Then I will close and wait for eslint to natively support this functonality.

@avaly
Copy link
Contributor Author

avaly commented Feb 21, 2017

@selaux I'm not sure how that plugin is supposed to help with the functionality I'm trying to get from this PR. AFAICT that plugin allows for disabling other plugins completely. This is not what I'm looking for though.

@selaux
Copy link
Owner

selaux commented Feb 22, 2017

Sorry, I thought you wanted to disable the whole plugin 🙁 . The thing is that this is basically a eslint inherent problem. You want to lint specific globbed files with specific rulesets, which eslint does not support yet as described in eslint/eslint#3611. I'm unsure on how to handle this to be honest as I don't want to introduce functionality that will be removed soon...

@avaly
Copy link
Contributor Author

avaly commented Feb 22, 2017

No, I do not want to disable the whole plugin and I don't want to lint specific globbed files with some rules.

Let's take an example from the tests in this PR, assuming the following file:

Foo.react.js:

export default class Foo {
  render() {
    return <span>Test Class</span>;
  }
}

Applying this rule with the default config of "filenames/match-exported": [2], would result in a lint error similar to: Filename 'Foo.react' must match the exported name 'Foo'.

However with the following config from this PR: "filenames/match-exported": [2, "", "\\.react"], there would be no lint error, since we strip the .react suffix from the filename before comparing with the exported name.

@avaly
Copy link
Contributor Author

avaly commented Feb 22, 2017

Disabling this rule for specific globbed files would not help with the following case:

Bar.react.js:

export default class Foo {
  render() {
    return <span>Test Class</span>;
  }
}

If I'd disable the filenames/match-exported rule completely for *.react.js files, then the above would not throw a lint error.

@avaly
Copy link
Contributor Author

avaly commented Mar 9, 2017

@selaux Any more thoughts on merging this PR?

@imevro
Copy link

imevro commented Apr 11, 2017

@selaux ping

@selaux
Copy link
Owner

selaux commented Apr 11, 2017

Sorry for the late response, as eslint/eslint#3611 is still a ongoing discussion which does seem to take even more time, I will merge this for now and remove it again once the respective eslint feature is merged.

@selaux selaux merged commit f008678 into selaux:master Apr 11, 2017
@imevro
Copy link

imevro commented Apr 11, 2017

@selaux awesome, thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants