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 a rule to enforce using React component index modules only for re-exporting #2

Merged
merged 4 commits into from
Oct 5, 2022

Conversation

tambeta
Copy link
Member

@tambeta tambeta commented Sep 30, 2022

From the README:

reexporting-index-modules

Detect React index modules matching the regular expression
[A-Z]\w+/index\.js$ and only allow these to only contain import declarations
importing from its containing directory and export declarations re-exporting
previously imported symbols.

This rule enforces using index.js modules only for collecting imports from within its containing directory and re-exporting these. This ensures that editors, PRs, diffs etc. are not littered with indistinguishable index.js files.

Testing

In your project, temporarily modify ESLint configuration so that plugins includes "voog" and rules contains only

"voog/reexporting-index-modules": ["error"]

Then clone eslint-voog, link it to your project and run ESLint over the codebase to inspect the results. Execute yarn test to run the test suite.

$ git clone git@github.com:Voog/eslint-voog.git
$ cd eslint-voog
$ git checkout rule_react_index_modules
$ yarn test
$ yarn link
$ cd /my/project
$ yarn link eslint-plugin-voog
$ npx eslint -- 'app/assets/javascripts/**/*.js'

In addition to `options`, propagate `filename` on the test set down to
each test case in `compileTests`.
Support experimental and proposed syntax in test cases.
@tambeta tambeta added the enhancement New feature or request label Sep 30, 2022
@tambeta tambeta self-assigned this Sep 30, 2022
Copy link
Member

@tanelj tanelj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Copy link

@pxska pxska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍🏻

@tambeta tambeta merged commit 1523239 into master Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants