@double-great/stylelint-a11y
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -34,6 +34,6 @@ | ||
var checkNodesForContentProperty = function checkNodesForContentProperty(node) { | ||
return node.nodes.filter(function (node) { | ||
return node.prop; | ||
}).some(function (node) { | ||
return node.prop.toLowerCase() === 'content'; | ||
return node.nodes.filter(function (n) { | ||
return n.prop; | ||
}).some(function (n) { | ||
return n.prop.toLowerCase() === 'content'; | ||
}); | ||
@@ -40,0 +40,0 @@ }; |
@@ -35,2 +35,35 @@ "use strict"; | ||
}] | ||
}); | ||
testRule({ | ||
ruleName: _index.ruleName, | ||
config: [true, { | ||
thresholdInPixels: 16 | ||
}], | ||
accept: [{ | ||
code: '.foo { }' | ||
}, { | ||
code: '.foo { font-size: 16px; }' | ||
}, { | ||
code: '.foo { font-size: 12pt; }' | ||
}, { | ||
code: '.bar { FONT-SIZE: 16PX; }' | ||
}, { | ||
code: '.baz { font-size: 1em; }' | ||
}], | ||
reject: [{ | ||
code: '.foo { font-size: 15px; }', | ||
message: _index.messages.expected('.foo'), | ||
line: 1, | ||
column: 3 | ||
}, { | ||
code: '.foo { font-size: 3pt; }', | ||
message: _index.messages.expected('.foo'), | ||
line: 1, | ||
column: 3 | ||
}, { | ||
code: '.bar { FONT-SIZE: 8PX; }', | ||
message: _index.messages.expected('.bar'), | ||
line: 1, | ||
column: 3 | ||
}] | ||
}); |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -26,3 +26,2 @@ | ||
exports.messages = messages; | ||
var THRESHOLD_IN_PX = 15; | ||
@@ -33,11 +32,11 @@ var pxToPt = function pxToPt(v) { | ||
var checkInPx = function checkInPx(value) { | ||
var checkInPx = function checkInPx(value, THRESHOLD_IN_PX) { | ||
return value.toLowerCase().endsWith('px') && parseFloat(value) < THRESHOLD_IN_PX; | ||
}; | ||
var checkInPt = function checkInPt(value) { | ||
var checkInPt = function checkInPt(value, THRESHOLD_IN_PX) { | ||
return value.toLowerCase().endsWith('pt') && parseFloat(value) < pxToPt(THRESHOLD_IN_PX); | ||
}; | ||
function _default(actual) { | ||
function _default(actual, options) { | ||
return function (root, result) { | ||
@@ -52,2 +51,3 @@ var validOptions = _stylelint.utils.validateOptions(result, ruleName, { | ||
var THRESHOLD_IN_PX = options && options.thresholdInPixels || 15; | ||
root.walkRules(function (rule) { | ||
@@ -67,3 +67,3 @@ var selector = null; | ||
var isRejected = rule.nodes.some(function (o) { | ||
return o.type === 'decl' && o.prop.toLowerCase() === 'font-size' && (checkInPx(o.value) || checkInPt(o.value)); | ||
return o.type === 'decl' && o.prop.toLowerCase() === 'font-size' && (checkInPx(o.value, THRESHOLD_IN_PX) || checkInPt(o.value, THRESHOLD_IN_PX)); | ||
}); | ||
@@ -70,0 +70,0 @@ |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _mediaPrefersColorScheme = _interopRequireDefault(require("./media-prefers-color-scheme")); | ||
var _mediaPrefersReducedMotion = _interopRequireDefault(require("./media-prefers-reduced-motion")); | ||
@@ -31,4 +33,2 @@ | ||
var _mediaPrefersColorScheme = _interopRequireDefault(require("./media-prefers-color-scheme")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -35,0 +35,0 @@ |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -15,0 +15,0 @@ |
@@ -9,4 +9,6 @@ "use strict"; | ||
var _stylelint = require("stylelint"); | ||
var _isCustomSelector = _interopRequireDefault(require("stylelint/lib/utils/isCustomSelector")); | ||
var _isStandardSyntaxAtRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxAtRule")); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
@@ -16,6 +18,4 @@ | ||
var _isStandardSyntaxAtRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxAtRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isCustomSelector = _interopRequireDefault(require("stylelint/lib/utils/isCustomSelector")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -60,3 +60,3 @@ | ||
var parentMatchedNode = parentNodes.some(function (parentNode) { | ||
if (!parentNode || !parentNode.nodes) return; | ||
if (!parentNode || !parentNode.nodes) return false; | ||
return parentNode.nodes.some(function (childrenNode) { | ||
@@ -63,0 +63,0 @@ var childrenNodes = childrenNode.nodes; |
@@ -9,5 +9,5 @@ "use strict"; | ||
var _stylelint = require("stylelint"); | ||
var _isCustomSelector = _interopRequireDefault(require("stylelint/lib/utils/isCustomSelector")); | ||
var _postcss = require("postcss"); | ||
var _isStandardSyntaxAtRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxAtRule")); | ||
@@ -18,5 +18,5 @@ var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _isStandardSyntaxAtRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxAtRule")); | ||
var _postcss = require("postcss"); | ||
var _isCustomSelector = _interopRequireDefault(require("stylelint/lib/utils/isCustomSelector")); | ||
var _stylelint = require("stylelint"); | ||
@@ -83,3 +83,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
var parentMatchedNode = parentNodes.some(function (parentNode) { | ||
if (!parentNode || !parentNode.nodes) return; | ||
if (!parentNode || !parentNode.nodes) return false; | ||
return parentNode.nodes.some(function (childrenNode) { | ||
@@ -86,0 +86,0 @@ var childrenNodes = childrenNode.nodes; |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -15,0 +15,0 @@ |
@@ -9,4 +9,2 @@ "use strict"; | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
@@ -16,2 +14,4 @@ | ||
var _stylelint = require("stylelint"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -18,0 +18,0 @@ |
@@ -9,4 +9,2 @@ "use strict"; | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
@@ -16,2 +14,4 @@ | ||
var _stylelint = require("stylelint"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -18,0 +18,0 @@ |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -15,0 +15,0 @@ |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -15,0 +15,0 @@ |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -15,0 +15,0 @@ |
@@ -9,6 +9,6 @@ "use strict"; | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
var _stylelint = require("stylelint"); | ||
var _isStandardSyntaxRule = _interopRequireDefault(require("stylelint/lib/utils/isStandardSyntaxRule")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -47,6 +47,7 @@ | ||
function hasAlready(parent, repalcedSelector, selector) { | ||
var nodes = parent.nodes.map(function (i) { | ||
if (i.type === 'rule') return i.selectors; | ||
}); | ||
function hasAlready(parent, replacedSelector, selector) { | ||
var nodes = parent.nodes.reduce(function (arr, i) { | ||
if (i.type === 'rule') arr.push(i.selectors); | ||
return arr; | ||
}, []); | ||
var hoveredSelector = selector.split(',').filter(function (o) { | ||
@@ -62,3 +63,3 @@ return o.match(/:hover/gi); | ||
return parent.nodes.some(function (i) { | ||
return i.type === 'rule' && i.selectors.indexOf(repalcedSelector) !== -1; | ||
return i.type === 'rule' && i.selectors.indexOf(replacedSelector) !== -1; | ||
}); | ||
@@ -65,0 +66,0 @@ } |
{ | ||
"name": "@double-great/stylelint-a11y", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Plugin for stylelint with a11y rules", | ||
@@ -41,19 +41,18 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.17.10", | ||
"@babel/core": "^7.18.5", | ||
"@babel/eslint-parser": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"eslint": "^8.17.0", | ||
"@babel/cli": "^7.18.10", | ||
"@babel/core": "^7.19.0", | ||
"@babel/eslint-parser": "^7.18.9", | ||
"@babel/preset-env": "^7.19.0", | ||
"eslint": "^8.23.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-config-stylelint": "^15.1.0", | ||
"eslint-config-stylelint": "^16.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.1", | ||
"jest": "^28.1.1", | ||
"jest-cli": "^28.1.1", | ||
"jest-preset-stylelint": "^5.0.4", | ||
"prettier": "^2.7.0", | ||
"jest": "^29.0.2", | ||
"jest-preset-stylelint": "^6.0.0", | ||
"prettier": "^2.7.1", | ||
"pretty-quick": "^3.1.3", | ||
"rimraf": "^3.0.2", | ||
"stylelint": "^14.9.1" | ||
"stylelint": "^14.11.0" | ||
}, | ||
@@ -63,3 +62,6 @@ "bugs": { | ||
}, | ||
"homepage": "https://github.com/double-great/stylelint-a11y#readme" | ||
"homepage": "https://github.com/double-great/stylelint-a11y#readme", | ||
"dependencies": { | ||
"postcss": "^8.4.16" | ||
} | ||
} |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -16,3 +16,3 @@ export const ruleName = 'a11y/content-property-no-static-value'; | ||
const checkNodesForContentProperty = (node) => | ||
node.nodes.filter((node) => node.prop).some((node) => node.prop.toLowerCase() === 'content'); | ||
node.nodes.filter((n) => n.prop).some((n) => n.prop.toLowerCase() === 'content'); | ||
@@ -51,2 +51,3 @@ function check(node) { | ||
} | ||
selector = node.selector; | ||
@@ -53,0 +54,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -14,3 +14,3 @@ # content-property-no-static-value | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -17,0 +17,0 @@ ```css |
@@ -46,1 +46,45 @@ import { messages, ruleName } from '../index'; | ||
}); | ||
testRule({ | ||
ruleName, | ||
config: [true, { thresholdInPixels: 16 }], | ||
accept: [ | ||
{ | ||
code: '.foo { }', | ||
}, | ||
{ | ||
code: '.foo { font-size: 16px; }', | ||
}, | ||
{ | ||
code: '.foo { font-size: 12pt; }', | ||
}, | ||
{ | ||
code: '.bar { FONT-SIZE: 16PX; }', | ||
}, | ||
{ | ||
code: '.baz { font-size: 1em; }', | ||
}, | ||
], | ||
reject: [ | ||
{ | ||
code: '.foo { font-size: 15px; }', | ||
message: messages.expected('.foo'), | ||
line: 1, | ||
column: 3, | ||
}, | ||
{ | ||
code: '.foo { font-size: 3pt; }', | ||
message: messages.expected('.foo'), | ||
line: 1, | ||
column: 3, | ||
}, | ||
{ | ||
code: '.bar { FONT-SIZE: 8PX; }', | ||
message: messages.expected('.bar'), | ||
line: 1, | ||
column: 3, | ||
}, | ||
], | ||
}); |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -10,12 +10,10 @@ export const ruleName = 'a11y/font-size-is-readable'; | ||
const THRESHOLD_IN_PX = 15; | ||
const pxToPt = (v) => 0.75 * v; | ||
const checkInPx = (value) => | ||
const checkInPx = (value, THRESHOLD_IN_PX) => | ||
value.toLowerCase().endsWith('px') && parseFloat(value) < THRESHOLD_IN_PX; | ||
const checkInPt = (value) => | ||
const checkInPt = (value, THRESHOLD_IN_PX) => | ||
value.toLowerCase().endsWith('pt') && parseFloat(value) < pxToPt(THRESHOLD_IN_PX); | ||
export default function (actual) { | ||
export default function (actual, options) { | ||
return (root, result) => { | ||
@@ -28,7 +26,11 @@ const validOptions = utils.validateOptions(result, ruleName, { actual }); | ||
const THRESHOLD_IN_PX = (options && options.thresholdInPixels) || 15; | ||
root.walkRules((rule) => { | ||
let selector = null; | ||
if (!isStandardSyntaxRule(rule)) { | ||
return; | ||
} | ||
selector = rule.selector; | ||
@@ -44,3 +46,3 @@ | ||
o.prop.toLowerCase() === 'font-size' && | ||
(checkInPx(o.value) || checkInPt(o.value)) | ||
(checkInPx(o.value, THRESHOLD_IN_PX) || checkInPt(o.value, THRESHOLD_IN_PX)) | ||
); | ||
@@ -47,0 +49,0 @@ }); |
@@ -14,3 +14,3 @@ # font-size-is-readable | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -36,1 +36,19 @@ ```css | ||
``` | ||
## Optional secondary options | ||
### `thresholdInPixels: number` | ||
Given: | ||
``` | ||
16 | ||
``` | ||
The following pattern is considered a violation: | ||
```css | ||
.foo { | ||
font-size: 15px; | ||
} | ||
``` |
import contentPropertyNoStaticValue from './content-property-no-static-value'; | ||
import fontSizeIsReadable from './font-size-is-readable'; | ||
import lineHeightIsVerticalRhythmed from './line-height-is-vertical-rhythmed'; | ||
import mediaPrefersColorScheme from './media-prefers-color-scheme'; | ||
import mediaPrefersReducedMotion from './media-prefers-reduced-motion'; | ||
@@ -12,3 +13,2 @@ import noDisplayNone from './no-display-none'; | ||
import selectorPseudoClassFocus from './selector-pseudo-class-focus'; | ||
import mediaPrefersColorScheme from './media-prefers-color-scheme'; | ||
@@ -15,0 +15,0 @@ export default { |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -39,2 +39,3 @@ export const ruleName = 'a11y/line-height-is-vertical-rhythmed'; | ||
} | ||
selector = node.selector; | ||
@@ -41,0 +42,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -13,3 +13,3 @@ # line-height-is-vertical-rhythmed | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -16,0 +16,0 @@ ```css |
@@ -1,7 +0,8 @@ | ||
import { utils } from 'stylelint'; | ||
import isCustomSelector from 'stylelint/lib/utils/isCustomSelector'; | ||
import isStandardSyntaxAtRule from 'stylelint/lib/utils/isStandardSyntaxAtRule'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import isStandardSyntaxSelector from 'stylelint/lib/utils/isStandardSyntaxSelector'; | ||
import isStandardSyntaxAtRule from 'stylelint/lib/utils/isStandardSyntaxAtRule'; | ||
import isCustomSelector from 'stylelint/lib/utils/isCustomSelector'; | ||
import { utils } from 'stylelint'; | ||
export const ruleName = 'a11y/media-prefers-color-scheme'; | ||
@@ -34,2 +35,3 @@ | ||
const index = targetProperties.indexOf(declaration.prop); | ||
currentSelector = targetProperties[index]; | ||
@@ -44,3 +46,4 @@ | ||
const parentMatchedNode = parentNodes.some((parentNode) => { | ||
if (!parentNode || !parentNode.nodes) return; | ||
if (!parentNode || !parentNode.nodes) return false; | ||
return parentNode.nodes.some((childrenNode) => { | ||
@@ -58,2 +61,3 @@ const childrenNodes = childrenNode.nodes; | ||
const index = targetProperties.indexOf(declaration.prop); | ||
if (currentSelector !== targetProperties[index]) return false; | ||
@@ -60,0 +64,0 @@ |
@@ -17,3 +17,3 @@ # media-prefers-color-scheme | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -20,0 +20,0 @@ ```css |
@@ -1,7 +0,7 @@ | ||
import { utils } from 'stylelint'; | ||
import { parse } from 'postcss'; | ||
import isCustomSelector from 'stylelint/lib/utils/isCustomSelector'; | ||
import isStandardSyntaxAtRule from 'stylelint/lib/utils/isStandardSyntaxAtRule'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import isStandardSyntaxSelector from 'stylelint/lib/utils/isStandardSyntaxSelector'; | ||
import isStandardSyntaxAtRule from 'stylelint/lib/utils/isStandardSyntaxAtRule'; | ||
import isCustomSelector from 'stylelint/lib/utils/isCustomSelector'; | ||
import { parse } from 'postcss'; | ||
import { utils } from 'stylelint'; | ||
@@ -18,5 +18,8 @@ export const ruleName = 'a11y/media-prefers-reduced-motion'; | ||
const index = targetProperties.indexOf(declaration.prop); | ||
if (currentSelector === 'animation-name' && targetProperties[index] === 'animation') | ||
return true; | ||
if (currentSelector !== targetProperties[index]) return false; | ||
if (declaration.value !== 'none') return false; | ||
@@ -48,3 +51,5 @@ | ||
const index = targetProperties.indexOf(declaration.prop); | ||
currentSelector = targetProperties[index]; | ||
if (targetProperties.indexOf(declaration.prop) >= 0 && declaration.value === 'none') { | ||
@@ -61,3 +66,4 @@ return false; | ||
const parentMatchedNode = parentNodes.some((parentNode) => { | ||
if (!parentNode || !parentNode.nodes) return; | ||
if (!parentNode || !parentNode.nodes) return false; | ||
return parentNode.nodes.some((childrenNode) => { | ||
@@ -72,5 +78,8 @@ const childrenNodes = childrenNode.nodes; | ||
const index = targetProperties.indexOf(declaration.prop); | ||
if (currentSelector === 'animation-name' && targetProperties[index] === 'animation') | ||
return true; | ||
if (currentSelector !== targetProperties[index]) return false; | ||
if (declaration.value !== 'none') return false; | ||
@@ -134,2 +143,3 @@ | ||
const media = parse('@media screen and (prefers-reduced-motion: reduce) {}'); | ||
media.nodes.forEach((o) => { | ||
@@ -139,2 +149,3 @@ o.raws.after = '\n'; | ||
const cloneRule = node.clone(); | ||
cloneRule.raws = { | ||
@@ -150,2 +161,3 @@ ...cloneRule.raws, | ||
} | ||
if (targetProperties.indexOf(o.prop) >= 0) { | ||
@@ -157,2 +169,3 @@ o.value = 'none'; | ||
node.before(media); | ||
return; | ||
@@ -159,0 +172,0 @@ } |
@@ -13,3 +13,3 @@ # media-prefers-reduced-motion | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -16,0 +16,0 @@ ```css |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -36,2 +36,3 @@ export const ruleName = 'a11y/no-display-none'; | ||
} | ||
selector = node.selector; | ||
@@ -38,0 +39,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -13,3 +13,3 @@ # no-display-none | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -16,0 +16,0 @@ ```css |
@@ -1,2 +0,2 @@ | ||
import { ruleName, messages } from '../index'; | ||
import { messages, ruleName } from '../index'; | ||
@@ -3,0 +3,0 @@ testRule({ |
@@ -1,4 +0,4 @@ | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { obsoleteAttributes } from './obsoleteAttributes'; | ||
import { utils } from 'stylelint'; | ||
@@ -36,2 +36,3 @@ export const ruleName = 'a11y/no-obsolete-attribute'; | ||
} | ||
selector = node.selector; | ||
@@ -38,0 +39,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -15,3 +15,3 @@ # no-obsolete-attribute | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -18,0 +18,0 @@ ```css |
@@ -1,2 +0,2 @@ | ||
import { ruleName, messages } from '../index'; | ||
import { messages, ruleName } from '../index'; | ||
@@ -3,0 +3,0 @@ testRule({ |
@@ -1,4 +0,4 @@ | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { obsoleteElements } from './obsoleteElements'; | ||
import { utils } from 'stylelint'; | ||
@@ -15,2 +15,3 @@ export const ruleName = 'a11y/no-obsolete-element'; | ||
} | ||
return !node.selectors.some((sel) => { | ||
@@ -36,2 +37,3 @@ return obsoleteElements.has(sel); | ||
} | ||
selector = node.selector; | ||
@@ -38,0 +40,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -14,3 +14,3 @@ # no-obsolete-element | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -17,0 +17,0 @@ ```css |
@@ -1,4 +0,5 @@ | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
export const ruleName = 'a11y/no-outline-none'; | ||
@@ -53,2 +54,3 @@ | ||
} | ||
selector = node.selector; | ||
@@ -55,0 +57,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -17,3 +17,3 @@ # no-outline-none | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -20,0 +20,0 @@ ```css |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -41,5 +41,7 @@ export const ruleName = 'a11y/no-spread-text'; | ||
let selector = null; | ||
if (!isStandardSyntaxRule(rule)) { | ||
return; | ||
} | ||
selector = rule.selector; | ||
@@ -46,0 +48,0 @@ |
@@ -16,3 +16,3 @@ # no-spread-text | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -19,0 +19,0 @@ ```css |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -38,2 +38,3 @@ export const ruleName = 'a11y/no-text-align-justify'; | ||
} | ||
selector = node.selector; | ||
@@ -40,0 +41,0 @@ } else if (node.type === 'atrule' && node.name.toLowerCase() === 'page' && node.params) { |
@@ -14,3 +14,3 @@ # no-text-align-justify | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -17,0 +17,0 @@ ```css |
@@ -0,3 +1,3 @@ | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
import { utils } from 'stylelint'; | ||
import isStandardSyntaxRule from 'stylelint/lib/utils/isStandardSyntaxRule'; | ||
@@ -12,6 +12,9 @@ const deepFlatten = (arr) => [].concat(...arr.map((v) => (Array.isArray(v) ? deepFlatten(v) : v))); | ||
function hasAlready(parent, repalcedSelector, selector) { | ||
const nodes = parent.nodes.map((i) => { | ||
if (i.type === 'rule') return i.selectors; | ||
}); | ||
function hasAlready(parent, replacedSelector, selector) { | ||
const nodes = parent.nodes.reduce((arr, i) => { | ||
if (i.type === 'rule') arr.push(i.selectors); | ||
return arr; | ||
}, []); | ||
const hoveredSelector = selector | ||
@@ -24,6 +27,7 @@ .split(',') | ||
}); | ||
if (returned) return true; | ||
return parent.nodes.some((i) => { | ||
return i.type === 'rule' && i.selectors.indexOf(repalcedSelector) !== -1; | ||
return i.type === 'rule' && i.selectors.indexOf(replacedSelector) !== -1; | ||
}); | ||
@@ -73,2 +77,3 @@ } | ||
}); | ||
return; | ||
@@ -75,0 +80,0 @@ } |
@@ -18,3 +18,3 @@ # selector-pseudo-class-focus | ||
The following pattern are considered violations: | ||
The following pattern is considered a violation: | ||
@@ -21,0 +21,0 @@ ```css |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
438286
16
114
3560
2
1
+ Addedpostcss@^8.4.16