eslint-plugin-react-cov
v3.4.1
Published
Custom ESLint react plugin and rules for COV, including folder naming conventions
Maintainers
Readme
eslint-plugin-react-cov
ESLint rules for COV React projects. The plugin enforces naming, file-extension, Kendo UI, Redux, and RTK Query conventions.
Installation
npm install --save-dev eslint-plugin-react-covRequirements
- Node.js >= 24.0.0
- ESLint 9 or 10
Usage
Use the recommended flat configuration:
import covReactRules from "eslint-plugin-react-cov";
export default [...covReactRules.configs.recommended];To enable individual rules instead:
import { defineConfig } from "eslint/config";
import covReactRules from "eslint-plugin-react-cov";
export default defineConfig([
{
plugins: {
"cov-react-rules": covReactRules
},
rules: {
"cov-react-rules/folders": "error",
"cov-react-rules/file-names": "error"
}
}
]);Rules
This plugin includes the following rules:
cov-react-rules/folders
Enforces snake_case naming convention for folders under the src directory.
For example, src/api_services is valid and src/APIServices is invalid.
cov-react-rules/file-names
Enforces specific naming conventions for files based on their location:
- Files in
srcsubfolders use PascalCase, or start withCOVfollowed by PascalCase. - Files in
src/hooksstart withusefollowed by PascalCase. - Files in
src/servicesend withApi, exceptErrorMiddleware.js.
cov-react-rules/js-jsx-check
Requires .jsx files when a file contains JSX and .js files when it does not.
cov-react-rules/file-extension-rules
Enforces extensions by source folder: lib, redux, services, and hooks use .js; components and pages use .jsx. The pages rule also applies to nested folders.
cov-react-rules/kendo-button-type
Requires Kendo Button components to declare a type attribute. The rule can autofix a missing attribute to type={"button"}.
cov-react-rules/kendo-id-prop
Requires configured base Kendo components to have an id. Statically known IDs must be camelCase and begin with cov.
cov-react-rules/form-component-boundaries
Requires fields inside a Kendo Form to use components from cov-kendo-form-components rather than direct Kendo components. The rule checks direct imports from @progress/kendo-react-* and allows the components listed in lib/rules/form-component-exceptions.json.
cov-react-rules/api-table-name
Requires every *Api.js file, except BaseApi.js, to declare a camelCase TABLE_NAME string and reference it in every endpoint url expression. For example, const TABLE_NAME = "streets" and url: /${TABLE_NAME}``.
cov-react-rules/redux-file-allowlist
Warns when a file other than AppNotificationSlice.js, AppSlice.js, or Store.js is added beneath src/redux. The warning keeps the code review visible without blocking applications that need an additional slice. Use RTK Query for API state whenever possible.
For an approved additional slice, configure the project-specific allowlist:
"cov-react-rules/redux-file-allowlist": ["warn", {
allowedFiles: ["AppNotificationSlice.js", "AppSlice.js", "Store.js", "FeatureSlice.js"]
}]cov-react-rules/rtk-query-method-kind
Requires statically known RTK Query request methods to use the matching endpoint builder:
GETrequests usebuilder.queryPOST,PUT, andDELETErequests usebuilder.mutation
The rule recognizes createApi imports from @reduxjs/toolkit/query and @reduxjs/toolkit/query/react. Configure an alternative module name when required:
"cov-react-rules/rtk-query-method-kind": ["error", {
apiModules: ["@reduxjs/toolkit/query/react", "@company/rtk-query"]
}]cov-react-rules/rtk-query-prefer-patch
Warns when an RTK Query mutation uses a static PUT method. Prefer PATCH where the API supports partial updates. This rule does not autofix because the server contract may require PUT.
Configuration
recommended enables the standard COV rules. redux-file-allowlist and rtk-query-prefer-patch use warn; the remaining recommended rules use error.
Use all to enable every exported rule, including rules added in future releases:
import covReactRules from "eslint-plugin-react-cov";
export default [...covReactRules.configs.all];Contributing
To contribute to this project:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
License
MIT
Author
Fabian Hanggi
