stylelint
Advanced tools
Comparing version 2.3.5 to 2.3.6
@@ -0,1 +1,6 @@ | ||
# 2.3.6 | ||
* Fixed: `rule-properties-order` now accounts for property names containing multiple hyphens. | ||
* Fixed: `rule-properties-order` grouping bug. | ||
# 2.3.5 | ||
@@ -2,0 +7,0 @@ |
@@ -22,3 +22,3 @@ "use strict"; | ||
return (0, _cosmiconfig2.default)("stylelint", { | ||
configPath: _path2.default.resolve(process.cwd(), options.configFile) | ||
configPath: _path2.default.resolve(process.cwd(), options.configFile || "") | ||
}).then(function (result) { | ||
@@ -49,3 +49,4 @@ return augmentConfig(result.config, _path2.default.dirname(result.filepath)); | ||
function augmentConfig(config, configDir) { | ||
function augmentConfig(nonnormalizedConfig, configDir) { | ||
var config = normalizeSeverities(nonnormalizedConfig); | ||
// Absolutize the plugins here, because here is the place | ||
@@ -69,3 +70,2 @@ // where we know the basedir for this particular config | ||
// Also returns a Promise ... | ||
function loadExtendedConfig(config, extendLookup) { | ||
@@ -84,3 +84,3 @@ var extendPath = (0, _resolveFrom2.default)(configDir, extendLookup); | ||
// Replace all plugin looksup with absolute paths | ||
// Replace all plugin lookups with absolute paths | ||
function absolutizePlugins(config, configDir) { | ||
@@ -103,2 +103,37 @@ if (!config.plugins) { | ||
} | ||
} | ||
// Temporary measure while there are 2 severity syntaxes. | ||
// This makes all severities numbered (the old syntax). | ||
function normalizeSeverities(config) { | ||
if (!config.rules) { | ||
return config; | ||
} | ||
var configHasNumberedSeverities = (0, _lodash.values)(config.rules).every(function (ruleSettings) { | ||
return typeof [].concat(ruleSettings)[0] === "number"; | ||
}); | ||
if (configHasNumberedSeverities) { | ||
return (0, _lodash.assign)({}, config, { | ||
numberedSeverities: true | ||
}); | ||
} | ||
return (0, _lodash.assign)({}, config, { | ||
rules: (0, _lodash.mapValues)(config.rules, function (ruleSettings) { | ||
if (ruleSettings === null) { | ||
return 0; | ||
} | ||
if (ruleSettings === true) { | ||
return 2; | ||
} | ||
if (ruleSettings[1] && ruleSettings[1].warn) { | ||
return [1].concat(ruleSettings); | ||
} | ||
return [2].concat(ruleSettings); | ||
}) | ||
}); | ||
} |
@@ -29,36 +29,22 @@ "use strict"; | ||
if (expectation === "never" && leftSpace !== "") { | ||
(0, _utils.report)({ | ||
message: messages.rejectedOpening, | ||
node: comment, | ||
index: opener.length, | ||
result: result, | ||
ruleName: ruleName | ||
}); | ||
complain(messages.rejectedOpening, opener.length); | ||
} | ||
if (expectation === "always" && !(0, _utils.isWhitespace)(leftSpace)) { | ||
(0, _utils.report)({ | ||
message: messages.expectedOpening, | ||
node: comment, | ||
index: opener.length, | ||
result: result, | ||
ruleName: ruleName | ||
}); | ||
complain(messages.expectedOpening, opener.length); | ||
} | ||
if (expectation === "never" && rightSpace !== "") { | ||
(0, _utils.report)({ | ||
message: messages.rejectedClosing, | ||
node: comment, | ||
index: comment.toString().length - closer.length - 1, | ||
result: result, | ||
ruleName: ruleName | ||
}); | ||
complain(messages.rejectedClosing, comment.toString().length - closer.length - 1); | ||
} | ||
if (expectation === "always" && !(0, _utils.isWhitespace)(rightSpace)) { | ||
complain(messages.expectedClosing, comment.toString().length - closer.length - 1); | ||
} | ||
function complain(message, index) { | ||
(0, _utils.report)({ | ||
message: messages.expectedClosing, | ||
node: comment, | ||
index: comment.toString().length - closer.length - 1, | ||
message: message, | ||
index: index, | ||
result: result, | ||
ruleName: ruleName | ||
ruleName: ruleName, | ||
node: comment | ||
}); | ||
@@ -65,0 +51,0 @@ } |
@@ -154,3 +154,3 @@ "use strict"; | ||
if (!firstPropIsUnspecified && !secondPropIsUnspecified) { | ||
return firstPropOrderValue.index <= secondPropOrderValue.index; | ||
return firstPropOrderValue.expectedPosition <= secondPropOrderValue.expectedPosition; | ||
} | ||
@@ -187,17 +187,28 @@ | ||
var expectedOrder = {}; | ||
var lineSeparatedGroup = 1; | ||
var expectedPosition = 0; | ||
appendGroup(input, 1); | ||
function appendGroup(items, startIndex) { | ||
items.forEach(function (item, index) { | ||
appendItem(item, index + startIndex); | ||
function appendGroup(items) { | ||
items.forEach(function (item) { | ||
return appendItem(item, false); | ||
}); | ||
} | ||
function appendItem(item, index) { | ||
function appendItem(item, inFlexibleGroup) { | ||
if (_lodash2["default"].isString(item)) { | ||
expectedOrder[item] = { index: index, lineSeparatedGroup: lineSeparatedGroup }; | ||
// In flexible groups, the expectedPosition does not ascend | ||
// to make that flexibility work; | ||
// otherwise, it will always ascend | ||
if (!inFlexibleGroup) { | ||
expectedPosition += 1; | ||
} | ||
expectedOrder[item] = { lineSeparatedGroup: lineSeparatedGroup, expectedPosition: expectedPosition }; | ||
return; | ||
} | ||
// If item is not a string, it's a group ... | ||
if (item.emptyLineBefore) { | ||
@@ -208,11 +219,11 @@ lineSeparatedGroup += 1; | ||
if (!item.order || item.order === "strict") { | ||
appendGroup(item.properties, index); | ||
appendGroup(item.properties); | ||
return; | ||
} else if (item.order === "flexible") { | ||
expectedPosition += 1; | ||
item.properties.forEach(function (property) { | ||
appendItem(property, index); | ||
appendItem(property, true); | ||
}); | ||
} | ||
} | ||
return expectedOrder; | ||
@@ -226,7 +237,7 @@ } | ||
// and use that index | ||
if (!orderValue && propName.indexOf("-") !== -1) { | ||
var propNamePreHyphen = propName.slice(0, propName.indexOf("-")); | ||
orderValue = expectedOrder[propNamePreHyphen]; | ||
if (!orderValue && propName.lastIndexOf("-") !== -1) { | ||
var propNamePreHyphen = propName.slice(0, propName.lastIndexOf("-")); | ||
orderValue = getOrderValue(expectedOrder, propNamePreHyphen); | ||
} | ||
return orderValue; | ||
} |
{ | ||
"name": "stylelint", | ||
"version": "2.3.5", | ||
"version": "2.3.6", | ||
"description": "Modern CSS linter", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -1,2 +0,2 @@ | ||
# stylelint [![NPM version](http://img.shields.io/npm/v/stylelint.svg)](https://www.npmjs.org/package/stylelint) [![Travis Build Status](https://img.shields.io/travis/stylelint/stylelint/master.svg?label=unix%20build)](https://travis-ci.org/stylelint/stylelint) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/MoOx/stylelint/master.svg?label=windows%20build)](https://ci.appveyor.com/project/MoOx/stylelint) [![Join the chat at https://gitter.im/stylelint/stylelint](https://img.shields.io/badge/gitter%20-join%20chat%20%E2%9E%9E-1dce73.svg)](https://gitter.im/stylelint/stylelint) | ||
# stylelint [![NPM version](http://img.shields.io/npm/v/stylelint.svg)](https://www.npmjs.org/package/stylelint) [![Travis Build Status](https://img.shields.io/travis/stylelint/stylelint/master.svg?label=unix%20build)](https://travis-ci.org/stylelint/stylelint) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/stylelint/stylelint/master.svg?label=windows%20build)](https://ci.appveyor.com/project/stylelint/stylelint) [![Join the chat at https://gitter.im/stylelint/stylelint](https://img.shields.io/badge/gitter%20-join%20chat%20%E2%9E%9E-1dce73.svg)](https://gitter.im/stylelint/stylelint) | ||
@@ -3,0 +3,0 @@ > Modern CSS linter. |
@@ -13,3 +13,3 @@ # declaration-colon-space-after | ||
`string`: `"always"|"never"` | ||
`string`: `"always"|"never"|"always-single-line"` | ||
@@ -72,3 +72,3 @@ ### `"always"` | ||
a { | ||
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8); | ||
box-shadow:0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8); | ||
} | ||
@@ -81,2 +81,8 @@ ``` | ||
a { | ||
box-shadow: 0 0 0 1px #5b9dd9, 0 0 2px 1px rgba(30, 140, 190, 0.8); | ||
} | ||
``` | ||
```css | ||
a { | ||
box-shadow: | ||
@@ -83,0 +89,0 @@ 0 0 0 1px #5b9dd9, |
@@ -134,3 +134,3 @@ import _ from "lodash" | ||
if (!firstPropIsUnspecified && !secondPropIsUnspecified) { | ||
return firstPropOrderValue.index <= secondPropOrderValue.index | ||
return firstPropOrderValue.expectedPosition <= secondPropOrderValue.expectedPosition | ||
} | ||
@@ -155,17 +155,24 @@ | ||
const expectedOrder = {} | ||
let lineSeparatedGroup = 1 | ||
let expectedPosition = 0 | ||
appendGroup(input, 1) | ||
function appendGroup(items, startIndex) { | ||
items.forEach((item, index) => { | ||
appendItem(item, index + startIndex) | ||
}) | ||
function appendGroup(items) { | ||
items.forEach(item => appendItem(item, false)) | ||
} | ||
function appendItem(item, index) { | ||
function appendItem(item, inFlexibleGroup) { | ||
if (_.isString(item)) { | ||
expectedOrder[item] = { index, lineSeparatedGroup } | ||
// In flexible groups, the expectedPosition does not ascend | ||
// to make that flexibility work; | ||
// otherwise, it will always ascend | ||
if (!inFlexibleGroup) { expectedPosition += 1 } | ||
expectedOrder[item] = { lineSeparatedGroup, expectedPosition } | ||
return | ||
} | ||
// If item is not a string, it's a group ... | ||
if (item.emptyLineBefore) { | ||
@@ -176,11 +183,11 @@ lineSeparatedGroup += 1 | ||
if (!item.order || item.order === "strict") { | ||
appendGroup(item.properties, index) | ||
appendGroup(item.properties) | ||
return | ||
} else if (item.order === "flexible") { | ||
expectedPosition += 1 | ||
item.properties.forEach(property => { | ||
appendItem(property, index) | ||
appendItem(property, true) | ||
}) | ||
} | ||
} | ||
return expectedOrder | ||
@@ -194,7 +201,7 @@ } | ||
// and use that index | ||
if (!orderValue && propName.indexOf("-") !== -1) { | ||
const propNamePreHyphen = propName.slice(0, propName.indexOf("-")) | ||
orderValue = expectedOrder[propNamePreHyphen] | ||
if (!orderValue && propName.lastIndexOf("-") !== -1) { | ||
const propNamePreHyphen = propName.slice(0, propName.lastIndexOf("-")) | ||
orderValue = getOrderValue(expectedOrder, propNamePreHyphen) | ||
} | ||
return orderValue | ||
} |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
10
641136
384
14032