Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hiro08gh/eslint-plugin-validate-filename
ESLint plugin validate filename. It can be verification by case and pattern and extensions.
https://github.com/hiro08gh/eslint-plugin-validate-filename
eslint eslint-plugin filename
Last synced: 2 days ago
JSON representation
ESLint plugin validate filename. It can be verification by case and pattern and extensions.
- Host: GitHub
- URL: https://github.com/hiro08gh/eslint-plugin-validate-filename
- Owner: hiro08gh
- License: mit
- Created: 2023-12-28T10:05:18.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-06T23:56:42.000Z (4 months ago)
- Last Synced: 2024-12-24T12:30:21.383Z (4 days ago)
- Topics: eslint, eslint-plugin, filename
- Language: TypeScript
- Homepage: https://medium.com/@hiro08gh/next-js-naming-conventions-are-checked-with-eslint-rules-946371d67882
- Size: 131 KB
- Stars: 21
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-validate-filename
ESLint rule to force file names format. Create common rules for file names by folder name or regex pattern.
## Install
```sh
npm install --save-dev eslint-plugin-validate-filename
```## Uasge
```javascript
{
"plugins": ["validate-filename"]
}
```### validate-filename/naming-rules
Create a rule in the name of ESLint. You can set multiple `rules`.
```javascript
{
"rules": {
"validate-filename/naming-rules": [
"error",
{
rules: [
{
case: 'pascal', // camel or pascal or snake or kebab or flat
target: "**/components/**", // target "components" folder
excludes: ['hooks'], // "hooks" folder is excluded.
}
{
case: 'camel',
target: "**/hooks/**", // target "hooks" folder
patterns: '^use', // file names begin with "use".
}
]
}
],
}
```### validate-filename/limit-extensions
Only certain extensions are allowed. `target` is a regular expression that identifies the folder. `extensions` you want to allow for extensions.
```javascript
{
"rules": {
"validate-filename/limit-extensions": [
"error",
{
rules: [
{
target: "**/hooks/**",
extensions: ['.ts', '.tsx'], // This cannot be created except for .ts or .tsx under the hooks folder.
}
]
}
],
}
```## Development
First, install npm dependencies.
```bash
npm install
```Running unit test. This library uses vitest.
```bash
npm run test
```Build modules.
```bash
npm run build
```## Next.js structure settings example
See [Next.js naming conventions are checked with ESLint rules](https://medium.com/@hiro08gh/next-js-naming-conventions-are-checked-with-eslint-rules-946371d67882)
article.## License
MIT License.© [hiro08gh](https://github.com/hiro08gh)