stylelint-a11y
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -71,3 +71,5 @@ 'use strict'; | ||
var checkNodesForContentProperty = function checkNodesForContentProperty(node) { | ||
return node.nodes.some(function (node) { | ||
return node.nodes.filter(function (node) { | ||
return node.prop; | ||
}).some(function (node) { | ||
return node.prop.toLowerCase() === 'content'; | ||
@@ -74,0 +76,0 @@ }); |
@@ -18,2 +18,4 @@ 'use strict'; | ||
}, { | ||
code: '.foo { font-size: 12pt; }' | ||
}, { | ||
code: '.bar { FONT-SIZE: 15PX; }' | ||
@@ -30,2 +32,7 @@ }, { | ||
}, { | ||
code: '.foo { font-size: 3pt; }', | ||
message: _index.messages.expected('.foo'), | ||
line: 1, | ||
column: 4 | ||
}, { | ||
code: '.bar { FONT-SIZE: 8PX; }', | ||
@@ -32,0 +39,0 @@ message: _index.messages.expected('.bar'), |
@@ -28,3 +28,3 @@ 'use strict'; | ||
var isRejected = rule.nodes.some(function (o) { | ||
return o.type === 'decl' && o.prop.toLowerCase() === 'font-size' && o.value.toLowerCase().endsWith('px') && parseFloat(o.value) < 15; | ||
return o.type === 'decl' && o.prop.toLowerCase() === 'font-size' && (checkInPx(o.value) || checkInPt(o.value)); | ||
}); | ||
@@ -59,2 +59,15 @@ | ||
} | ||
}); | ||
}); | ||
var THRESHOLD_IN_PX = 15; | ||
var pxToPt = function pxToPt(v) { | ||
return 0.75 * v; | ||
}; | ||
var checkInPx = function checkInPx(value) { | ||
return value.toLowerCase().endsWith('px') && parseFloat(value) < THRESHOLD_IN_PX; | ||
}; | ||
var checkInPt = function checkInPt(value) { | ||
return value.toLowerCase().endsWith('pt') && parseFloat(value) < pxToPt(THRESHOLD_IN_PX); | ||
}; |
{ | ||
"name": "stylelint-a11y", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Plugin for stylelint with a11y rules", | ||
@@ -45,3 +45,3 @@ "main": "dist/index.js", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^8.2.5", | ||
"babel-eslint": "^10.0.1", | ||
"babel-preset-env": "^1.7.0", | ||
@@ -51,15 +51,15 @@ "babel-preset-jest": "^23.2.0", | ||
"coveralls": "^3.0.2", | ||
"eslint": "^5.1.0", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-config-stylelint": "^8.1.0", | ||
"eslint-plugin-import": "^2.13.0", | ||
"eslint-plugin-prettier": "^2.6.2", | ||
"jest": "^23.3.0", | ||
"jest-cli": "^23.3.0", | ||
"lodash": "^4.17.10", | ||
"prettier": "^1.13.7", | ||
"eslint": "^5.6.1", | ||
"eslint-config-prettier": "^3.1.0", | ||
"eslint-config-stylelint": "^8.3.0", | ||
"eslint-plugin-import": "^2.14.0", | ||
"eslint-plugin-prettier": "^3.0.0", | ||
"jest": "^23.6.0", | ||
"jest-cli": "^23.6.0", | ||
"lodash": "^4.17.11", | ||
"prettier": "^1.14.3", | ||
"rimraf": "^2.6.2", | ||
"stylelint": "^9.3.0", | ||
"stylelint": "^9.6.0", | ||
"stylelint-test-rule-tape": "^0.2.0" | ||
} | ||
} |
@@ -16,3 +16,3 @@ import { utils } from 'stylelint'; | ||
const checkNodesForContentProperty = node => | ||
node.nodes.some(node => node.prop.toLowerCase() === 'content'); | ||
node.nodes.filter(node => node.prop).some(node => node.prop.toLowerCase() === 'content'); | ||
@@ -19,0 +19,0 @@ function check(node) { |
@@ -15,2 +15,5 @@ import rule, { messages, ruleName } from '../index'; | ||
{ | ||
code: '.foo { font-size: 12pt; }', | ||
}, | ||
{ | ||
code: '.bar { FONT-SIZE: 15PX; }', | ||
@@ -31,2 +34,8 @@ }, | ||
{ | ||
code: '.foo { font-size: 3pt; }', | ||
message: messages.expected('.foo'), | ||
line: 1, | ||
column: 4, | ||
}, | ||
{ | ||
code: '.bar { FONT-SIZE: 8PX; }', | ||
@@ -33,0 +42,0 @@ message: messages.expected('.bar'), |
@@ -10,2 +10,11 @@ import { utils } from 'stylelint'; | ||
const THRESHOLD_IN_PX = 15; | ||
const pxToPt = v => 0.75 * v; | ||
const checkInPx = value => | ||
value.toLowerCase().endsWith('px') && parseFloat(value) < THRESHOLD_IN_PX; | ||
const checkInPt = value => | ||
value.toLowerCase().endsWith('pt') && parseFloat(value) < pxToPt(THRESHOLD_IN_PX); | ||
export default function(actual) { | ||
@@ -34,4 +43,3 @@ return (root, result) => { | ||
o.prop.toLowerCase() === 'font-size' && | ||
o.value.toLowerCase().endsWith('px') && | ||
parseFloat(o.value) < 15 | ||
(checkInPx(o.value) || checkInPt(o.value)) | ||
); | ||
@@ -38,0 +46,0 @@ }); |
# font-size-large-enough | ||
Disallow font sizes less than 15px. | ||
Disallow font sizes less than 15px (or 11.25pt). | ||
@@ -5,0 +5,0 @@ **Sources:** |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312937
2734