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

support filename check #162

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add folder name convention
  • Loading branch information
yuxing committed May 22, 2024
commit c4933b9262df2dc714bda7f71ae02ed2c5c50628
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ module.exports = {
ignoreMiddleExtensions: true,
},
],
'check-file/folder-naming-convention': [
'error',
{
'src/**/!(__tests__)': 'KEBAB_CASE',
},
],
},
},
],
Expand Down
26 changes: 26 additions & 0 deletions docs/project-standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,29 @@ For TypeScript (`tsconfig.json`) projects:
```

It is also possible to define multiple paths for various folders(such as `@components`, `@hooks`, etc.), but using `@/*` works very well because it is short enough so there is no need to configure multiple paths and it differs from other dependency modules so there is no confusion in what comes from `node_modules` and what is our source folder. That means that anything in the `src` folder can be accessed via `@`, e.g some file that lives in `src/components/my-component` can be accessed using `@/components/my-component` instead of `../../../components/my-component`.

#### File naming conventions

We can also enforce the file naming conventions and folder naming conventions in the project. For example, you can enforce that all files should be named in `kebab-case`. This can help you to keep your codebase consistent and easier to navigate.

To enforce this, you can use ESLint:

```js
'check-file/filename-naming-convention': [
'error',
{
'**/*.{ts,tsx}': 'KEBAB_CASE',
},
{
// ignore the middle extensions of the filename to support filename like bable.config.js or smoke.spec.ts
ignoreMiddleExtensions: true,
},
],
'check-file/folder-naming-convention': [
'error',
{
// all folders within src (except __tests__)should be named in kebab-case
'src/**/!(__tests__)': 'KEBAB_CASE',
},
],
```
17 changes: 0 additions & 17 deletions docs/project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,5 @@ To enforce this, you can use ESLint:
],
```

We can also enforce the file naming conventions. For example, you can enforce that all files should be named in `kebab-case`. This can help you to keep your codebase consistent and easier to navigate.

To enforce this, you can use ESLint:

```js
'check-file/filename-naming-convention': [
'error',
{
'**/*.{ts,tsx}': 'KEBAB_CASE',
},
{
// ignore the middle extensions of the filename to support filename like bable.config.js or smoke.spec.ts
ignoreMiddleExtensions: true,
},
],
```

By following these practices, you can ensure that your codebase is well-organized, scalable, and maintainable. This will help you and your team to work more efficiently and effectively on the project.
This approach can also make it easier to apply similar architecture to apps built with Next.js, Remix or React Native.