@mrhenry/stylelint-mrhenry-invalid-of-type-selectors 1.0.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,14 +2,31 @@
2
2
 
3
3
  [![version](https://img.shields.io/npm/v/@mrhenry/stylelint-mrhenry-invalid-of-type-selectors.svg)](https://www.npmjs.com/package/@mrhenry/stylelint-mrhenry-invalid-of-type-selectors)
4
4
 
5
- Warn when `:first-of-type` and similar selectors are used in selectors that do not match at least one type.
6
- This rule is not fully accurate and will have false negatives (`foo .bar:first-of-type`), but it is accurate enough to create awareness around the general issue.
5
+ Disallow ambiguous `*-of-type` selectors.
7
6
 
8
7
  ```css
9
- /* invalid, the selector isn't a type selector */
10
- .foo:first-of-type {}
11
-
12
8
  /* valid, the selector is a type selector */
13
9
  strong:first-of-type {}
10
+
11
+ /* invalid, the selector isn't a type selector */
12
+ .foo:first-of-type {}
14
13
  ```
15
14
 
15
+ Warns when `:first-of-type` and similar selectors are used in selectors that do not match at least one type.
16
+ This rule is not fully accurate and will have false negatives (`foo .bar:first-of-type`), but it is accurate enough to create awareness around the general issue.
17
+
18
+ ## Usage
19
+
20
+ `npm install --save-dev @mrhenry/stylelint-mrhenry-invalid-of-type-selectors`
21
+
22
+ ```js
23
+ // stylelint.config.js
24
+ module.exports = {
25
+ plugins: [
26
+ "@mrhenry/stylelint-mrhenry-invalid-of-type-selectors",
27
+ ],
28
+ rules: {
29
+ "@mrhenry/stylelint-mrhenry-invalid-of-type-selectors": true,
30
+ },
31
+ }
32
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrhenry/stylelint-mrhenry-invalid-of-type-selectors",
3
- "version": "1.0.2",
3
+ "version": "2.0.1",
4
4
  "description": "Warn when :first-of-type is used with class selectors",
5
5
  "main": "stylelint-mrhenry-invalid-of-type-selectors.js",
6
6
  "scripts": {
@@ -16,7 +16,6 @@
16
16
  "directory": "packages/invalid-of-type-selectors"
17
17
  },
18
18
  "files": [
19
- "order.js",
20
19
  "stylelint-mrhenry-invalid-of-type-selectors.js",
21
20
  "LICENSE",
22
21
  "README.md"
@@ -35,6 +34,6 @@
35
34
  "stylelint": "^14.16.1 || ^15.0.0"
36
35
  },
37
36
  "devDependencies": {
38
- "stylelint": "^15.0.0"
37
+ "stylelint": "^15.2.0"
39
38
  }
40
39
  }
@@ -1,7 +1,7 @@
1
1
  const stylelint = require("stylelint");
2
2
  const selectorParser = require('postcss-selector-parser');
3
3
 
4
- const ruleName = "plugin/stylelint-mrhenry-invalid-of-type-selectors";
4
+ const ruleName = "@mrhenry/stylelint-mrhenry-invalid-of-type-selectors";
5
5
  const messages = stylelint.utils.ruleMessages(ruleName, {
6
6
  expected: (name) => {
7
7
  return `Expected a type selector with ${name}.`;
@@ -21,6 +21,10 @@ const ofTypeSelectors = [
21
21
 
22
22
  const ruleFunction = (primaryOption, secondaryOptionObject, context) => {
23
23
  return (postcssRoot, postcssResult) => {
24
+ if (!primaryOption) {
25
+ return;
26
+ }
27
+
24
28
  postcssRoot.walkRules((rule) => {
25
29
  {
26
30
  const lowerCaseSelector = rule.selector.toLowerCase();