eslint-plugin-filenames icon indicating copy to clipboard operation
eslint-plugin-filenames copied to clipboard

Add match-exported = [parent folder]-[filename] pattern

Open interactivellama opened this issue 6 years ago • 2 comments

This is a great plugin for code reviewers! I mean how often does one forget to check the file name in Github?

I'm getting this error and was curious if there was a way to get around it:

design-system-react/components/accordion/panel.jsx
  8:1  error  Filename 'panel' must match the exported and transformed name 'accordion-panel'  filenames/match-exported

design-system-react/components/alert/container.jsx
  6:1  error  Filename 'container' must match the exported and transformed name 'alert-container'  filenames/match-exported

The pattern is [parent folder]-[filename] in kabob case. I don't mind PR'ing this if it's a simple pattern to match. I'd imagine the regex would go back before the last slash in the path and add that to a hyphen and the filename.

interactivellama avatar Feb 01 '18 23:02 interactivellama

In my case, sometimes I also have a grandparent folder, i.e.: src/components/base/card/header.js, where we expect the component to be default exported as BaseCardHeader.

What changes should I do to accomplish this?

fsmaia avatar Feb 01 '19 21:02 fsmaia

As an alternative you can use https://github.com/Igorkowalski94/eslint-plugin-project-structure has the same capabilities + force only folders/files, has a built-in case for name, regex support, ability to inherit the name from the parent (the child inherits the name of the folder in which it is located), folder recursion (You can nest a given folder structure recursively).

Igorkowalski94 avatar Oct 01 '23 13:10 Igorkowalski94