eslint-plugin-react-require-testid
Advanced tools
Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "eslint-plugin-react-require-testid", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "lib/index.js", | ||
@@ -9,5 +9,21 @@ "license": "MIT", | ||
}, | ||
"keywords": [], | ||
"keywords": [ | ||
"ESLint", | ||
"React", | ||
"Testing", | ||
"Linting", | ||
"Code Quality", | ||
"JSX", | ||
"Configuration", | ||
"Custom ESLint Rules", | ||
"Plugin Development", | ||
"JavaScript", | ||
"Static Analysis", | ||
"Code Standards", | ||
"Development Best Practices", | ||
"Configuration Management", | ||
"Automated Testing" | ||
], | ||
"author": "", | ||
"description": "", | ||
"description": "This ESLint plugin helps ensure that React components have the necessary testID attribute, which is crucial for effective testing of React applications.", | ||
"repository": { | ||
@@ -14,0 +30,0 @@ "type": "git", |
# eslint-plugin-react-require-testid | ||
This ESLint plugin is used for ensuring the testID attribute is on all relevant components in React. | ||
This ESLint plugin helps ensure that React components have the necessary testID attribute, which is crucial for effective testing of React applications. | ||
@@ -13,3 +13,3 @@ ## Installation | ||
Configure ESLint to use the plugin. Add it to the ESLint configuration: | ||
After installation, you need to configure ESLint to use this rule. Here's an example configuration: | ||
@@ -20,3 +20,6 @@ ```javascript | ||
"rules": { | ||
"react-require-testid/testid-missing": "error" | ||
"react-require-testid/testid-missing": ["error", { | ||
"disableDefaultComponents": [], | ||
"enableComponents": [] | ||
}] | ||
} | ||
@@ -26,2 +29,27 @@ } | ||
In this configuration: | ||
- `disableDefaultComponents` allows you to specify default components to exclude from the rule check. | ||
- `enableComponents` allows you to specify additional components to include in the rule check. | ||
###### Rule Logic | ||
- The rule iterates through JSX opening elements in your code. | ||
- It filters out default React components based on the configuration. | ||
- It merges the filtered default components with any additional components specified. | ||
- For each JSX opening element, it checks if the component is allowed and if it has a `testID` attribute. | ||
- If the component is allowed but lacks a `testID` attribute, a linting error is reported. | ||
###### Example | ||
Consider the following JSX code snippet: | ||
`<MyCustomComponent />` | ||
With the ESLint rule configured, it will raise a linting error if `MyCustomComponent` is included in the allowed components list but does not have a `testID` attribute. | ||
###### Contributing | ||
Contributions to this ESLint rule are welcome! If you encounter issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub. | ||
## Conventional Commits | ||
@@ -28,0 +56,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9066
78