Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@mands/eslint-plugin
Advanced tools
Enforces best practices with data-testid by disallowing it on semantic elements, or ARIA generic elements with ARIA attributes
A collection of custom ESLint rules we use here at M&S to help maintain code quality. Rules can be opted into individually to provide more control over which rules you want to use and at what level of severity.
pnpm i -D @mands/eslint-plugin
# OR
yarn add --dev @mands/eslint-plugin
# OR
npm i --save-dev @mands/eslint-plugin
// .eslintrc
{
"plugins": ["@mands/eslint-plugin"],
"rules": {
"@mands/eslint-plugin/jsx-disallow-testid-on-semantic-elements": "error"
},
...
}
Enforces best practices with data-testid
as dictated by the React-Testing-Library Docs, by disallowing it on elements with semantic meaning or ARIA generic elements with ARIA attributes.
Supports React components by supplying data-testid (or data-test-id) through props.
Works by checking JSXElements, the Rule differentiates between HTML Elements and React Components within JSX by checking if the JSXElement begins with a capital letter - so will only work in projects following these best practices.
<!-- ✅ Valid - ARIA Generic element, with no semantic meaning -->
<div data-testid="test">
...
</div>
<!-- ❌ Invalid - element has ARIA semantic attributes, and should be selected with them -->
<div data-testid="test" role="test" aria-label="test">
...
</div>
<!-- ❌ Invalid - semantic element's should avoid use of data-testid -->
<ul data-testid="test">
...
</ul>
<!-- ❌ Invalid - same as above, alternate spelling -->
<ul data-test-id="test">
...
</ul>
// ✅ Valid - ARIA Generic element, with no semantic meaning
const Test = ({'data-testid': dataTestId}) => (
<div data-testid={dataTestId}>
...
</div>);
const Test2 = () => (<Test data-testid='test'></Test>)
// ❌ Invalid - semantic element's should avoid use of data-testid
const Test = ({'data-testid': dataTestId}) => (
<nav data-testid={dataTestId}>
...
</nav>);
const Test2 = () => (<Test data-testid='test'></Test>)
// ❌ Invalid - element has ARIA semantic attributes, and should be selected with them
const Test = ({'data-testid': dataTestId}) => (
<div data-testid={dataTestId} role="test" aria-label="test">
...
</div>);
const Test2 = () => (<Test data-testid='test'></Test>)
data-testid
's use on any ARIA generic element, this uses aria-query for the current accessibility web standards.data-testid
data-testid
through component props.data-testid
usage on semantic and generic elements.data-test-id
FAQs
Enforces best practices with data-testid by disallowing it on semantic elements, or ARIA generic elements with ARIA attributes
The npm package @mands/eslint-plugin receives a total of 0 weekly downloads. As such, @mands/eslint-plugin popularity was classified as not popular.
We found that @mands/eslint-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.