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

docs(examples): prevent internal imports via eslint #3503

Merged
merged 3 commits into from
Mar 17, 2019

Conversation

Fabianopb
Copy link
Member

Following up #3494 , @levithomason had the idea to prevent local imports in the docs examples via linter. Here's one solution: we have a local .eslintrc in the examples preventing undesired import patterns. However the rule is not valid for the index.js files in the same folder, so I've disabled the rule for those files.

Now the eslint will complain if there's a local import in the examples, like this:
Screen Shot 2019-03-14 at 15 29 47
Screen Shot 2019-03-14 at 15 40 27

Related to this PR, it seems that the prettier has done some additional changes to some of the index.js files. The docs seem to still work fine, but I wonder why that happened...

I'd be glad to get some feedback!
Cheers!

@codecov-io
Copy link

codecov-io commented Mar 14, 2019

Codecov Report

Merging #3503 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3503   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files         172      172           
  Lines        2804     2804           
=======================================
  Hits         2799     2799           
  Misses          5        5

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d40dad2...61174ca. Read the comment docs.

@layershifter
Copy link
Member

Instead of editing all files, I suggest to add overrides:

"overrides": [
 {
  "files": ["index.js"],
     "rules": {
        "no-restricted-imports": "off"   
     }
 }

@Fabianopb
Copy link
Member Author

Well pointed @layershifter, I didn't know you could override rules like this, thanks!

@layershifter layershifter changed the title docs(examples): Prevent internal imports via eslint. docs(examples): prevent internal imports via eslint Mar 17, 2019
Copy link
Member

@layershifter layershifter left a comment

Choose a reason for hiding this comment

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

👍

@layershifter layershifter merged commit 68932ca into master Mar 17, 2019
@delete-merged-branch delete-merged-branch bot deleted the lint-restricted-paths branch March 17, 2019 13:58
mbakiev pushed a commit to mbakiev/Semantic-UI-React that referenced this pull request Jun 17, 2019
* docs(examples): Prevent internal imports via eslint.

* Revert "docs(examples): Prevent internal imports via eslint."

This reverts commit 592f4a2.

* docs(example): Override index.js files to not use imports rule.
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.

3 participants