eslint-config-convention-fdel68
v6.0.2
Published
Filesystem and Naming conventions for exports, variables, components name, required files and folders to follow the correct format for Package structure.
Downloads
7
Maintainers
Readme
Design System Standards for Components
Filesystem and Naming conventions for exports, variables, components name, required files and folders to follow the correct format for Package structure.
Convention stablished in FDEL68: Create Linting for package filesystem structure and naming convention.
Installation
The package is intalled as usual, it's required to move configuration files into config/
folder to the root of the project. A yarn/npx command which executes lint-staged with this configuration files is also required (preferred from .husky/pre-commit
) as yarn lint-staged --config convention-FDEL68...
(one for each configuration).
Naming
It requires two extra files that should be at the project root convention-FDEL68-naming.config.js
and convention-FDEL68.naming-rules.config.json
.
convention-FDEL68-naming.config.js will receive just the commited files, then will filter them removing markdown files and json files to lint just component related ones.
convention-FDEL68.naming-rules.config.json will provide the convention-FDEL68-naming.config.js for file rules. It's just a custom configuration file which implements the convention package.
Run at pre-commit only
Currently, to acheive the whole convention topics, the configuration is splitted in two files which requires specific implementation:
As first step, install the convention as a NPM Package yarn add --dev eslint-config-convention-FDEL68 -W
Config
- project root : drop the files
convention-FDEL68-naming.config.js
andconvention-FDEL68.naming-rules.config.json
- .husky/pre-commit : include in lint-staged command
yarn lint-staged --config convention-FDEL68-naming.config.js
Acceptance Criteria
- [x] Naming
- folder/filenames
- should be kebab-case
- types/Components
- should be PascalCase
- default export
- should be named export
- folder/filenames
File System Structure
It requires one extra files that should be at the project root convention-FDEL68-filesystem.config.js
.
convention-FDEL68-filesystem.config.js will receive a list of commited files as an array of strings, then it will validate the component package folders structure (based in acceptance criteria) and it will check for required files.
- .husky/pre-commit : include in lint-staged command
yarn lint-staged --config convention-FDEL68-filesystem.config.js
File System Structure Scheme
- Query : Top Level
- packages/component-name
- Query : Root level (Component)
- ../files-in-root
- ../src/
- Query : Src level
- ../component-files
- ../utils/
- Misc : Src level
Acceptance Criteria
- File system
[x] component-name/ : Component level
- should have a README
- should have a stories
- should have a chromatic.stories
Misc :
- [x] all sub-components should live inside src/components folder
- [x] all utilities should live inside src/utils folder
- [x] unexpected folder name under /src (allowed only /components and /utils
- [x] should have a index file inside each folder
theorical assumptions about sub-component folder
A Compoenent package has the following structure:
- Component folder (as root)
- src folder (component files)
- utils (inside src folder)
- finally, files related to configs and testing
- src folder (component files)
Because of this structure, where src/ and dist/ folders are the only folders in the component package, we could assume that "any other folder would be a sub-component". Then it is possible to invalidate the presence of any other folder than src.