Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
eslint-plugin-cypress-best-practices
Advanced tools
An ESLint plugin for your Cypress tests.
Note: If you installed ESLint globally then you must also install eslint-plugin-cypress-best-practices
globally.
npm install eslint-plugin-cypress-best-practices --save-dev
or
yarn add eslint-plugin-cypress-best-practices --dev
Add an .eslintrc.json
file to your cypress
directory with the following:
{
"plugins": [
"cypress-best-practices"
]
}
You can add rules:
{
"rules": {
"cypress-best-practices/enforce-page-object-model": "error",
"cypress-best-practices/no-duplicate-selectors": "error",
"cypress-best-practices/no-simple-selectors": "warn",
}
}
enforce-page-object-model
The cy.get command should be limited to page object files, any cy.get with a string literal will be detected with some minor exclusions.
it('use literal string in cy.get', () => {
...
/**
* Will throw 'No literal string selectors inside test files.'
*/
cy.get('#form > button:nth-child(1)').click()
...
})
no-duplicate-selectors
This applies to the page object model, when a return expression contains a cy.get() action, it will compared with other return expressions to avoid duplicates.
class HomePage {
get loginButton() {
return cy.get('#form > .actions > nth-child(1)');
}
get loginBtn() {
/**
* Will throw 'No duplicate Cypress selectors.'
*/
return cy.get('#form > .actions > nth-child(1)');
}
}
no-simple-selectors
Any literal string selector that is only alphanumeric will be flagged.
class HomePage {
get loginButton() {
return cy.get('#form > .actions > nth-child(1)');
}
get productImage() {
/**
* Will throw 'No generic selectors.'
*/
return cy.get('img');
}
}
To add a new rule:
Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
FAQs
An ESLint plugin for your Cypress tests.
The npm package eslint-plugin-cypress-best-practices receives a total of 1,840 weekly downloads. As such, eslint-plugin-cypress-best-practices popularity was classified as popular.
We found that eslint-plugin-cypress-best-practices demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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 researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.