Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@corva/eslint-plugin-test-selectors

Package Overview
Dependencies
Maintainers
14
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@corva/eslint-plugin-test-selectors - npm Package Compare versions

Comparing version 0.0.0-c339759 to 1.0.0

4

CHANGELOG.md
# Changelog
- `1.0.0` - initial release
- `1.0.0` - initial release.
- removed `@corva/test-selectors/onClick` rule autofix
- made `testAttribute` case-sensitive.

@@ -18,9 +18,9 @@ /**

rules: {
'test-selectors/anchor': 'warn',
'test-selectors/button': 'warn',
'test-selectors/input': 'warn',
'test-selectors/onChange': 'warn',
'test-selectors/onClick': 'warn',
'test-selectors/onKeyDown': 'warn',
'test-selectors/onKeyUp': 'warn',
'@corva/test-selectors/anchor': 'warn',
'@corva/test-selectors/button': 'warn',
'@corva/test-selectors/input': 'warn',
'@corva/test-selectors/onChange': 'warn',
'@corva/test-selectors/onClick': 'warn',
'@corva/test-selectors/onKeyDown': 'warn',
'@corva/test-selectors/onKeyUp': 'warn',
},

@@ -35,9 +35,9 @@ },

rules: {
'test-selectors/anchor': 'error',
'test-selectors/button': 'error',
'test-selectors/input': 'error',
'test-selectors/onChange': 'error',
'test-selectors/onClick': 'error',
'test-selectors/onKeyDown': 'error',
'test-selectors/onKeyUp': 'error',
'@corva/test-selectors/anchor': 'error',
'@corva/test-selectors/button': 'error',
'@corva/test-selectors/input': 'error',
'@corva/test-selectors/onChange': 'error',
'@corva/test-selectors/onClick': 'error',
'@corva/test-selectors/onKeyDown': 'error',
'@corva/test-selectors/onKeyUp': 'error',
},

@@ -44,0 +44,0 @@ },

@@ -17,3 +17,4 @@ const { elementType, getProp, getPropValue } = require('jsx-ast-utils');

/* Determines the value of an HTML Node prop/attribute. */
const getValue = (node, prop) => getPropValue(getProp(node.attributes, prop));
const getValue = (node, prop) =>
getPropValue(getProp(node.attributes, prop, { ignoreCase: false }));

@@ -20,0 +21,0 @@ /* Determines if a node's attribute passes a filter test. */

{
"name": "@corva/eslint-plugin-test-selectors",
"version": "0.0.0-c339759",
"version": "1.0.0",
"description": "Makes sure test DOM attributes (e.g. data-test-id) are added to interactive DOM elements.",

@@ -19,5 +19,2 @@ "repository": {

"license": "ISC",
"engines": {
"yarn": "^1"
},
"main": "lib/index.js",

@@ -28,6 +25,10 @@ "scripts": {

"eslint": "eslint .",
"publish-patch": "yarn version --patch && yarn publish && git push --tags && git push",
"publish-minor": "yarn version --minor && yarn publish && git push --tags && git push",
"publish-major": "yarn version --major && yarn publish && git push --tags && git push",
"publish-test": "yarn publish --tag test",
"yrn-publish-patch": "yarn version --patch && yarn publish && git push --tags && git push",
"yrn-publish-minor": "yarn version --minor && yarn publish && git push --tags && git push",
"yrn-publish-major": "yarn version --major && yarn publish && git push --tags && git push",
"yrn-publish-test": "yarn publish --tag test",
"npm-publish-patch": "npm version patch && npm publish && git push --tags && git push",
"npm-publish-minor": "npm version minor && npm publish && git push --tags && git push",
"npm-publish-major": "npm version major && npm publish && git push --tags && git push",
"npm-publish-test": "npm publish --tag test",
"prepare": "husky install"

@@ -34,0 +35,0 @@ },

# eslint-plugin-test-selectors
Enforces that a `data-test-id` attribute is present on interactive DOM elements to help with UI testing.
Enforces that a `data-test-id` (case-sensitive) attribute is present on interactive DOM elements to help with UI testing.

@@ -24,7 +24,7 @@ - ❌ `<button>Download</button>`

Add `test-selectors` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
Add `@corva/test-selectors` to the plugins section of your `.eslintrc` configuration file:
```json
{
"plugins": ["test-selectors"]
"plugins": ["@corva/test-selectors"]
}

@@ -37,9 +37,9 @@ ```

{
"extends": ["plugin:test-selectors/recommended"]
"extends": ["plugin:@corva/test-selectors/recommended"]
}
```
By default, this will run all [Supported Rules](#supported-rules) and emit eslint warnings. If you want to be more strict, you can emit eslint errors by instead using `plugin:test-selectors/recommendedWithErrors`.
By default, this will run all [Supported Rules](#supported-rules) and emit eslint warnings. If you want to be more strict, you can emit eslint errors by instead using `plugin:@corva/test-selectors/recommendedWithErrors`.
Another option: you can also selectively enable and disable individual rules in the `rules` section of your `.eslintrc` configuration. For instance, if you only want to enable the `test-selectors/button` rule, skip the `extends` addition above and simply add the following to the `rules` section of your `.eslintrc` configuration:
Another option: you can also selectively enable and disable individual rules in the `rules` section of your `.eslintrc` configuration. For instance, if you only want to enable the `@corva/test-selectors/button` rule, skip the `extends` addition above and simply add the following to the `rules` section of your `.eslintrc` configuration:

@@ -49,3 +49,3 @@ ```json

"rules": {
"test-selectors/button": ["warn", "always"]
"@corva/test-selectors/button": ["warn", "always"]
}

@@ -60,3 +60,3 @@ }

"rules": {
"test-selectors/anchor": "off"
"@corva/test-selectors/anchor": "off"
}

@@ -79,3 +79,7 @@ }

"rules": {
"test-selectors/onChange": ["warn", "always", { "testAttribute": "data-some-custom-attribute" }]
"@corva/test-selectors/onChange": [
"warn",
"always",
{ "testAttribute": "data-some-custom-attribute" }
]
}

@@ -90,3 +94,7 @@ }

"rules": {
"test-selectors/onChange": ["warn", "always", { "testAttribute": ["data-testid", "testId"] }]
"@corva/test-selectors/onChange": [
"warn",
"always",
{ "testAttribute": ["data-testid", "testId"] }
]
}

@@ -103,3 +111,3 @@ }

"rules": {
"test-selectors/onChange": ["warn", "always", { "ignoreDisabled": false }]
"@corva/test-selectors/onChange": ["warn", "always", { "ignoreDisabled": false }]
}

@@ -116,3 +124,3 @@ }

"rules": {
"test-selectors/onChange": ["warn", "always", { "ignoreReadonly": false }]
"@corva/test-selectors/onChange": ["warn", "always", { "ignoreReadonly": false }]
}

@@ -129,3 +137,3 @@ }

"rules": {
"test-selectors/button": ["warn", "always", { "htmlOnly": true }]
"@corva/test-selectors/button": ["warn", "always", { "htmlOnly": true }]
}

@@ -137,9 +145,9 @@ }

- `test-selectors/anchor`
- `test-selectors/button`
- `test-selectors/input`
- `test-selectors/onChange`
- `test-selectors/onClick`
- `test-selectors/onKeyDown`
- `test-selectors/onKeyUp`
- `test-selectors/onSubmit`
- `@corva/test-selectors/anchor`
- `@corva/test-selectors/button`
- `@corva/test-selectors/input`
- `@corva/test-selectors/onChange`
- `@corva/test-selectors/onClick`
- `@corva/test-selectors/onKeyDown`
- `@corva/test-selectors/onKeyUp`
- `@corva/test-selectors/onSubmit`

@@ -52,3 +52,4 @@ /**

},
{ code: `<a data-TeSt-Id='foo'>Foo</a>`, errors: [anchorError] },
].map(parserOptionsMapper),
});

@@ -54,3 +54,4 @@ /**

},
{ code: `<button data-TeSt-Id='foo'>Foo</button>`, errors: [buttonError] },
].map(parserOptionsMapper),
});

@@ -43,3 +43,4 @@ /**

},
{ code: `<input data-TeSt-Id='foo'>Foo</input>`, errors: [inputError] },
].map(parserOptionsMapper),
});

@@ -58,3 +58,4 @@ /**

},
{ code: `<div onChange={ () => {} } data-TeSt-Id="bar">Foo</div>`, errors: [onChangeError] },
].map(parserOptionsMapper),
});

@@ -77,3 +77,4 @@ /**

},
{ code: `<div onClick={ () => {} } data-TeSt-Id="bar">Foo</div>`, errors: [onClickError] },
].map(parserOptionsMapper),
});

@@ -58,3 +58,4 @@ /**

},
{ code: `<div onKeyDown={ () => {} } data-TeSt-Id="bar">Foo</div>`, errors: [onKeyDownError] },
].map(parserOptionsMapper),
});

@@ -58,3 +58,4 @@ /**

},
{ code: `<div onKeyUp={ () => {} } data-TeSt-Id="bar">Foo</div>`, errors: [onKeyUpError] },
].map(parserOptionsMapper),
});

@@ -58,3 +58,4 @@ /**

},
{ code: `<form onSubmit={ () => {} } data-TeSt-Id="bar">Foo</form>`, errors: [onSubmitError] },
].map(parserOptionsMapper),
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc