stylelint-z-index-value-constraint
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
## v1.2.0 | ||
- Added: support for stylelint versions 11, 12, 13, and 14. | ||
## v1.1.0 | ||
@@ -2,0 +6,0 @@ |
115
index.js
@@ -22,3 +22,3 @@ const stylelint = require("stylelint"); | ||
Number.isNaN || | ||
function(value) { | ||
function (value) { | ||
return value !== value; | ||
@@ -31,65 +31,68 @@ }; | ||
module.exports = stylelint.createPlugin(ruleName, function(options, secondary) { | ||
return function(cssRoot, result) { | ||
const validOptions = stylelint.utils.validateOptions( | ||
result, | ||
ruleName, | ||
{ | ||
actual: options, | ||
possible: { | ||
min: possibleValueTest, | ||
max: possibleValueTest | ||
module.exports = stylelint.createPlugin( | ||
ruleName, | ||
function (options, secondary) { | ||
return function (cssRoot, result) { | ||
const validOptions = stylelint.utils.validateOptions( | ||
result, | ||
ruleName, | ||
{ | ||
actual: options, | ||
possible: { | ||
min: possibleValueTest, | ||
max: possibleValueTest | ||
} | ||
}, | ||
{ | ||
actual: secondary, | ||
possible: { | ||
ignoreValues: [isNumber] | ||
}, | ||
optional: true | ||
} | ||
}, | ||
{ | ||
actual: secondary, | ||
possible: { | ||
ignoreValues: [isNumber] | ||
}, | ||
optional: true | ||
); | ||
if (!validOptions) { | ||
return; | ||
} | ||
); | ||
if (!validOptions) { | ||
return; | ||
} | ||
cssRoot.walkDecls("z-index", function (decl) { | ||
const value = Number(decl.value); | ||
cssRoot.walkDecls("z-index", function(decl) { | ||
const value = Number(decl.value); | ||
if ( | ||
_isNaN(value) || | ||
(secondary && | ||
Array.isArray(secondary.ignoreValues) && | ||
secondary.ignoreValues.indexOf(value) > -1) | ||
) { | ||
return; | ||
} | ||
if ( | ||
_isNaN(value) || | ||
(secondary && | ||
Array.isArray(secondary.ignoreValues) && | ||
secondary.ignoreValues.indexOf(value) > -1) | ||
) { | ||
return; | ||
} | ||
if (options.max && Math.abs(value) > options.max) { | ||
stylelint.utils.report({ | ||
ruleName, | ||
result, | ||
node: decl, | ||
message: messages.largerThanMax( | ||
isNegative(value) ? options.max * -1 : options.max | ||
) | ||
}); | ||
} | ||
if (options.max && Math.abs(value) > options.max) { | ||
stylelint.utils.report({ | ||
ruleName, | ||
result, | ||
node: decl, | ||
message: messages.largerThanMax( | ||
isNegative(value) ? options.max * -1 : options.max | ||
) | ||
}); | ||
} | ||
if (options.min && Math.abs(value) < options.min) { | ||
stylelint.utils.report({ | ||
ruleName, | ||
result, | ||
node: decl, | ||
message: messages.smallerThanMin( | ||
isNegative(value) ? options.min * -1 : options.min | ||
) | ||
}); | ||
} | ||
}); | ||
}; | ||
} | ||
); | ||
if (options.min && Math.abs(value) < options.min) { | ||
stylelint.utils.report({ | ||
ruleName, | ||
result, | ||
node: decl, | ||
message: messages.smallerThanMin( | ||
isNegative(value) ? options.min * -1 : options.min | ||
) | ||
}); | ||
} | ||
}); | ||
}; | ||
}); | ||
module.exports.ruleName = ruleName; | ||
module.exports.messages = messages; |
{ | ||
"name": "stylelint-z-index-value-constraint", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Stylelint rule for setting minimum and maximum constraint value for z-index.", | ||
@@ -26,15 +26,16 @@ "main": "index.js", | ||
"peerDependencies": { | ||
"stylelint": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0" | ||
"stylelint": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^10.0.1", | ||
"eslint": "^5.16.0", | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^7.31.0", | ||
"eslint-plugin-sort-requires": "^2.1.0", | ||
"husky": "^1.3.1", | ||
"jest": "^24.7.1", | ||
"jest-cli": "^24.7.1", | ||
"lint-staged": "^8.1.5", | ||
"npmpub": "^4.1.0", | ||
"prettier": "^1.17.0", | ||
"stylelint": "^10.0.1" | ||
"husky": "^7.0.1", | ||
"jest": "^27.0.6", | ||
"jest-cli": "^27.0.6", | ||
"jest-preset-stylelint": "^4.2.0", | ||
"lint-staged": "^11.0.1", | ||
"npmpub": "^5.0.0", | ||
"prettier": "^2.3.2", | ||
"stylelint": "^14.1.0" | ||
}, | ||
@@ -41,0 +42,0 @@ "engines": { |
# stylelint-z-index-value-constraint | ||
[](https://greenkeeper.io/) | ||
[](https://www.npmjs.com/package/stylelint-z-index-value-constraint) | ||
[](https://travis-ci.org/kristerkari/stylelint-z-index-value-constraint) | ||
[](https://ci.appveyor.com/project/kristerkari/stylelint-z-index-value-constraint/branch/master) | ||
[](https://github.com/kristerkari/stylelint-z-index-value-constraint/actions?workflow=Tests) | ||
[](http://npmcharts.com/compare/stylelint-z-index-value-constraint) | ||
@@ -9,0 +6,0 @@ [](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github) |
83
3.75%9649
-0.29%11
10%179
-1.65%