mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-13 05:13:33 -06:00
Initial commit
This commit is contained in:
21
node_modules/stylelint-scss/dist/index.js
generated
vendored
Normal file
21
node_modules/stylelint-scss/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("./utils");
|
||||
|
||||
var _rules = require("./rules");
|
||||
|
||||
var _rules2 = _interopRequireDefault(_rules);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var rulesPlugins = Object.keys(_rules2.default).map(function (ruleName) {
|
||||
return (0, _stylelint.createPlugin)((0, _utils.namespace)(ruleName), _rules2.default[ruleName]);
|
||||
});
|
||||
|
||||
exports.default = rulesPlugins;
|
33
node_modules/stylelint-scss/dist/rules/at-else-closing-brace-newline-after/index.js
generated
vendored
Normal file
33
node_modules/stylelint-scss/dist/rules/at-else-closing-brace-newline-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always-last-in-chain"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _atIfClosingBraceNewlineAfter.sassConditionalBraceNLAfterChecker)({ root: root, result: result, ruleName: ruleName, atRuleName: "else", expectation: expectation, messages: messages });
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _atIfClosingBraceNewlineAfter = require("../at-if-closing-brace-newline-after");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-else-closing-brace-newline-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected newline after \"}\" of @else statement",
|
||||
rejected: "Unexpected newline after \"}\" of @else statement"
|
||||
});
|
33
node_modules/stylelint-scss/dist/rules/at-else-closing-brace-space-after/index.js
generated
vendored
Normal file
33
node_modules/stylelint-scss/dist/rules/at-else-closing-brace-space-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always-intermediate", "never-intermediate"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _atIfClosingBraceSpaceAfter.sassConditionalBraceSpaceAfterChecker)({ root: root, result: result, ruleName: ruleName, atRuleName: "else", expectation: expectation, messages: messages });
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _atIfClosingBraceSpaceAfter = require("../at-if-closing-brace-space-after");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-else-closing-brace-space-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected single space after \"}\" of @else statement",
|
||||
rejected: "Unexpected space after \"}\" of @else statement"
|
||||
});
|
49
node_modules/stylelint-scss/dist/rules/at-else-empty-line-before/index.js
generated
vendored
Normal file
49
node_modules/stylelint-scss/dist/rules/at-else-empty-line-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["never"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkAtRules(function (atrule) {
|
||||
|
||||
if (atrule.name !== "else") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't need to ignore "the first rule in a stylesheet", etc, cases
|
||||
// because @else should always go after @if
|
||||
|
||||
if (!(0, _utils.hasEmptyLine)(atrule.raws.before)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.rejected,
|
||||
node: atrule,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-else-empty-line-before");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: "Unxpected empty line before @else"
|
||||
});
|
39
node_modules/stylelint-scss/dist/rules/at-extend-no-missing-placeholder/index.js
generated
vendored
Normal file
39
node_modules/stylelint-scss/dist/rules/at-extend-no-missing-placeholder/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (actual) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual });
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkAtRules("extend", function (atrule) {
|
||||
var isPlaceholder = atrule.params.trim()[0] === "%";
|
||||
var isInterpolation = /^#{.+}/.test(atrule.params.trim());
|
||||
|
||||
if (!isPlaceholder && !isInterpolation) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: atrule,
|
||||
message: messages.rejected
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-extend-no-missing-placeholder");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: "Expected a placeholder selector (e.g. %placeholder) to be used in @extend"
|
||||
});
|
51
node_modules/stylelint-scss/dist/rules/at-function-pattern/index.js
generated
vendored
Normal file
51
node_modules/stylelint-scss/dist/rules/at-function-pattern/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (pattern) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: pattern,
|
||||
possible: [_lodash.isRegExp, _lodash.isString]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var regexpPattern = (0, _lodash.isString)(pattern) ? new RegExp(pattern) : pattern;
|
||||
|
||||
root.walkAtRules(function (decl) {
|
||||
if (decl.name !== "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stripping the function of its arguments
|
||||
var funcName = decl.params.replace(/(\s*?)\((?:\s|\S)*\)/g, "");
|
||||
if (regexpPattern.test(funcName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-function-pattern");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected @function name to match specified pattern"
|
||||
});
|
93
node_modules/stylelint-scss/dist/rules/at-if-closing-brace-newline-after/index.js
generated
vendored
Normal file
93
node_modules/stylelint-scss/dist/rules/at-if-closing-brace-newline-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always-last-in-chain"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
sassConditionalBraceNLAfterChecker({ root: root, result: result, ruleName: ruleName, atRuleName: "if", expectation: expectation, messages: messages });
|
||||
};
|
||||
};
|
||||
|
||||
exports.sassConditionalBraceNLAfterChecker = sassConditionalBraceNLAfterChecker;
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-if-closing-brace-newline-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected newline after \"}\" of @if statement",
|
||||
rejected: "Unexpected newline after \"}\" of @if statement"
|
||||
});
|
||||
|
||||
/**
|
||||
* The core logic for this rule. Can be imported by other rules with similar
|
||||
* logic, namely at-else-closing-brace-newline-after
|
||||
*
|
||||
* @param {Object} args -- Named arguments object
|
||||
* @param {PostCSS root} args.root
|
||||
* @param {PostCSS result} args.result
|
||||
* @param {String ruleName} args.ruleName - needed for `report` function
|
||||
* @param {String} args.atRuleName - the name of the at-rule to be checked, e.g. "if", "else"
|
||||
* @param {Object} args.messages - returned by stylelint.utils.ruleMessages
|
||||
* @return {undefined}
|
||||
*/
|
||||
function sassConditionalBraceNLAfterChecker(_ref) {
|
||||
var root = _ref.root,
|
||||
result = _ref.result,
|
||||
ruleName = _ref.ruleName,
|
||||
atRuleName = _ref.atRuleName,
|
||||
expectation = _ref.expectation,
|
||||
messages = _ref.messages;
|
||||
|
||||
function complain(node, message, index) {
|
||||
_stylelint.utils.report({
|
||||
result: result,
|
||||
ruleName: ruleName,
|
||||
node: node,
|
||||
message: message,
|
||||
index: index
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules(function (atrule) {
|
||||
// Do nothing if it's not an @if
|
||||
if (atrule.name !== atRuleName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nextNode = atrule.next();
|
||||
if (!nextNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nextBefore = nextNode.raws.before;
|
||||
var hasNewLinesBeforeNext = nextBefore && !(0, _utils.isSingleLineString)(nextBefore);
|
||||
var reportIndex = atrule.toString().length;
|
||||
|
||||
if (expectation === "always-last-in-chain") {
|
||||
// If followed by @else, no newline is needed
|
||||
if (nextNode.type === "atrule" && nextNode.name === "else") {
|
||||
if (hasNewLinesBeforeNext) {
|
||||
complain(atrule, messages.rejected, reportIndex);
|
||||
}
|
||||
} else {
|
||||
if (!hasNewLinesBeforeNext) {
|
||||
complain(atrule, messages.expected, reportIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
87
node_modules/stylelint-scss/dist/rules/at-if-closing-brace-space-after/index.js
generated
vendored
Normal file
87
node_modules/stylelint-scss/dist/rules/at-if-closing-brace-space-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always-intermediate", "never-intermediate"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
sassConditionalBraceSpaceAfterChecker({ root: root, result: result, ruleName: ruleName, atRuleName: "if", expectation: expectation, messages: messages });
|
||||
};
|
||||
};
|
||||
|
||||
exports.sassConditionalBraceSpaceAfterChecker = sassConditionalBraceSpaceAfterChecker;
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-if-closing-brace-space-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected single space after \"}\" of @if statement",
|
||||
rejected: "Unexpected space after \"}\" of @if statement"
|
||||
});
|
||||
|
||||
/**
|
||||
* The core logic for this rule. Can be imported by other rules with similar
|
||||
* logic, namely at-else-closing-brace-space-after
|
||||
*
|
||||
* @param {Object} args -- Named arguments object
|
||||
* @param {PostCSS root} args.root
|
||||
* @param {PostCSS result} args.result
|
||||
* @param {String ruleName} args.ruleName - needed for `report` function
|
||||
* @param {String} args.atRuleName - the name of the at-rule to be checked, e.g. "if", "else"
|
||||
* @param {Object} args.messages - returned by stylelint.utils.ruleMessages
|
||||
* @return {undefined}
|
||||
*/
|
||||
function sassConditionalBraceSpaceAfterChecker(_ref) {
|
||||
var root = _ref.root,
|
||||
result = _ref.result,
|
||||
ruleName = _ref.ruleName,
|
||||
atRuleName = _ref.atRuleName,
|
||||
expectation = _ref.expectation,
|
||||
messages = _ref.messages;
|
||||
|
||||
function complain(node, message, index) {
|
||||
_stylelint.utils.report({
|
||||
result: result,
|
||||
ruleName: ruleName,
|
||||
node: node,
|
||||
message: message,
|
||||
index: index
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules(function (atrule) {
|
||||
// Do nothing if it's not an @if
|
||||
if (atrule.name !== atRuleName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nextNode = atrule.next();
|
||||
var hasSpaceAfter = nextNode && nextNode.raws.before === " ";
|
||||
var hasWhiteSpaceAfter = nextNode && nextNode.raws.before !== "";
|
||||
var reportIndex = atrule.toString().length;
|
||||
|
||||
// When followed by an @else
|
||||
if (nextNode && nextNode.type === "atrule" && nextNode.name === "else") {
|
||||
// A single space is needed
|
||||
if (expectation === "always-intermediate" && !hasSpaceAfter) {
|
||||
complain(atrule, messages.expected, reportIndex);
|
||||
} else if (expectation === "never-intermediate" && hasWhiteSpaceAfter) {
|
||||
// No whitespace is needed
|
||||
complain(atrule, messages.rejected, reportIndex);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
88
node_modules/stylelint-scss/dist/rules/at-import-no-partial-extension/index.js
generated
vendored
Normal file
88
node_modules/stylelint-scss/dist/rules/at-import-no-partial-extension/index.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (on, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: on
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
// Accepting array of either strings or regular expressions
|
||||
ignoreExtensions: function ignoreExtensions(str) {
|
||||
return (0, _lodash.isRegExp)(str) || (0, _lodash.isString)(str);
|
||||
}
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
result.warn("The 'at-import-no-partial-extension' rule has been deprecated, " + "and will be removed in '2.0'. Instead, use 'at-import-partial-extension-blacklist' or 'at-import-partial-extension-whitelist' rules.", {
|
||||
stylelintType: "deprecation"
|
||||
});
|
||||
|
||||
function checkPathForUnderscore(path, decl) {
|
||||
// Stripping trailing quotes and whitespaces, if any
|
||||
var pathStripped = path.replace(/^\s*?("|')\s*/, "").replace(/\s*("|')\s*?$/, "");
|
||||
var extension = _path2.default.extname(pathStripped).slice(1);
|
||||
|
||||
// If the extension is not empty
|
||||
if (!extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skipping importing CSS: url(), ".css", URI with a protocol, media
|
||||
if (pathStripped.slice(0, 4) === "url(" || pathStripped.slice(-4) === ".css" || pathStripped.search("//") !== -1 || pathStripped.search(/(?:\s|[,)"'])\w+$/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options && options.ignoreExtensions) {
|
||||
// Return if...
|
||||
if (options.ignoreExtensions.some(function (ignoredExt) {
|
||||
// the extension matches one of the ignored strings or Regexps
|
||||
return (0, _lodash.isString)(ignoredExt) && ignoredExt === extension || (0, _lodash.isRegExp)(ignoredExt) && extension.search(ignoredExt) !== -1;
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules("import", function (atRule) {
|
||||
// Processing comma-separated lists of import paths
|
||||
atRule.params.split(",").forEach(function (path) {
|
||||
checkPathForUnderscore(path, atRule);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-import-no-partial-extension");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Unexpected file extension in imported partial name"
|
||||
});
|
54
node_modules/stylelint-scss/dist/rules/at-import-no-partial-leading-underscore/index.js
generated
vendored
Normal file
54
node_modules/stylelint-scss/dist/rules/at-import-no-partial-leading-underscore/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (actual) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual });
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkPathForUnderscore(path, decl) {
|
||||
// Stripping trailing quotes and whitespaces, if any
|
||||
var pathStripped = path.replace(/^\s*?("|')\s*/, "").replace(/\s*("|')\s*?$/, "");
|
||||
|
||||
// Searching a _ at the start of filename
|
||||
if (pathStripped.search(/(?:^|\/|\\)_[^/]+$/) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skipping importing CSS: url(), ".css", URI with a protocol, media
|
||||
if (pathStripped.slice(0, 4) === "url(" || pathStripped.slice(-4) === ".css" || pathStripped.search("//") !== -1 || pathStripped.search(/(?:\s|[,)"'])\w+$/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules("import", function (decl) {
|
||||
// Processing comma-separated lists of import paths
|
||||
decl.params.split(",").forEach(function (path) {
|
||||
checkPathForUnderscore(path, decl);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-import-no-partial-leading-underscore");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Unexpected leading underscore in imported partial name"
|
||||
});
|
76
node_modules/stylelint-scss/dist/rules/at-import-partial-extension-blacklist/index.js
generated
vendored
Normal file
76
node_modules/stylelint-scss/dist/rules/at-import-partial-extension-blacklist/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (blacklistOption) {
|
||||
var blacklist = [].concat(blacklistOption);
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: blacklistOption,
|
||||
possible: [_lodash.isString, _lodash.isRegExp]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkPathForUnderscore(path, decl) {
|
||||
// Stripping trailing quotes and whitespaces, if any
|
||||
var pathStripped = path.replace(/^\s*?("|')\s*/, "").replace(/\s*("|')\s*?$/, "");
|
||||
var extension = _path2.default.extname(pathStripped).slice(1);
|
||||
// Save this separately to be able to pass the original string to report()
|
||||
var extensionNormalized = extension.toLowerCase();
|
||||
|
||||
// If the extension is empty
|
||||
if (!extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skipping importing CSS: url(), ".css", URI with a protocol, media
|
||||
if (pathStripped.slice(0, 4) === "url(" || pathStripped.slice(-4) === ".css" || pathStripped.search("//") !== -1 || pathStripped.search(/(?:\s|[,)"'])\w+$/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
blacklist.forEach(function (ext) {
|
||||
if ((0, _lodash.isString)(ext) && extensionNormalized === ext || (0, _lodash.isRegExp)(ext) && extensionNormalized.search(ext) !== -1) {
|
||||
_stylelint.utils.report({
|
||||
message: messages.rejected(extension),
|
||||
node: decl,
|
||||
word: extension,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules("import", function (atRule) {
|
||||
// Processing comma-separated lists of import paths
|
||||
atRule.params.split(",").forEach(function (path) {
|
||||
checkPathForUnderscore(path, atRule);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-import-partial-extension-blacklist");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: function rejected(ext) {
|
||||
return "Unexpected extension \"." + ext + "\" in imported partial name";
|
||||
}
|
||||
});
|
78
node_modules/stylelint-scss/dist/rules/at-import-partial-extension-whitelist/index.js
generated
vendored
Normal file
78
node_modules/stylelint-scss/dist/rules/at-import-partial-extension-whitelist/index.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (whitelistOption) {
|
||||
var whitelist = [].concat(whitelistOption);
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: whitelistOption,
|
||||
possible: [_lodash.isString, _lodash.isRegExp]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
function checkPathForUnderscore(path, decl) {
|
||||
// Stripping trailing quotes and whitespaces, if any
|
||||
var pathStripped = path.replace(/^\s*?("|')\s*/, "").replace(/\s*("|')\s*?$/, "");
|
||||
var extension = _path2.default.extname(pathStripped).slice(1);
|
||||
// Save this separately to be able to pass the original string to report()
|
||||
var extensionNormalized = extension.toLowerCase();
|
||||
|
||||
// If the extension is empty
|
||||
if (!extension) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skipping importing CSS: url(), ".css", URI with a protocol, media
|
||||
if (pathStripped.slice(0, 4) === "url(" || pathStripped.slice(-4) === ".css" || pathStripped.search("//") !== -1 || pathStripped.search(/(?:\s|[,)"'])\w+$/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (whitelist.some(function (ext) {
|
||||
return (0, _lodash.isString)(ext) && extensionNormalized === ext || (0, _lodash.isRegExp)(ext) && extensionNormalized.search(ext) !== -1;
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.rejected(extension),
|
||||
node: decl,
|
||||
word: extension,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
|
||||
root.walkAtRules("import", function (atRule) {
|
||||
// Processing comma-separated lists of import paths
|
||||
atRule.params.split(",").forEach(function (path) {
|
||||
checkPathForUnderscore(path, atRule);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-import-partial-extension-whitelist");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: function rejected(ext) {
|
||||
return "Unexpected extension \"." + ext + "\" in imported partial name";
|
||||
}
|
||||
});
|
53
node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
generated
vendored
Normal file
53
node_modules/stylelint-scss/dist/rules/at-mixin-argumentless-call-parentheses/index.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (value) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: value,
|
||||
possible: ["always", "never"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkAtRules("include", function (mixinCall) {
|
||||
// If it is "No parens in argumentless calls"
|
||||
if (value === "never" && mixinCall.params.search(/\(\s*?\)\s*?$/) === -1) {
|
||||
return;
|
||||
}
|
||||
// If it is "Always use parens"
|
||||
if (value === "always" && mixinCall.params.search(/\(/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var mixinName = /\s*(\S*?)\s*(?:\(|$)/.exec(mixinCall.params)[1];
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages[value === "never" ? "rejected" : "expected"](mixinName),
|
||||
node: mixinCall,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-mixin-no-argumentless-call-parentheses");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: function expected(mixin) {
|
||||
return "Expected parentheses in mixin \"" + mixin + "\" call";
|
||||
},
|
||||
rejected: function rejected(mixin) {
|
||||
return "Unexpected parentheses in argumentless mixin \"" + mixin + "\" call";
|
||||
}
|
||||
});
|
38
node_modules/stylelint-scss/dist/rules/at-mixin-no-argumentless-call-parentheses/index.js
generated
vendored
Normal file
38
node_modules/stylelint-scss/dist/rules/at-mixin-no-argumentless-call-parentheses/index.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (actual) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual });
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkAtRules("include", function (decl) {
|
||||
if (decl.params.search(/\(\s*?\)\s*?$/) === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-mixin-no-argumentless-call-parentheses");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Unexpected parentheses in argumentless @mixin call"
|
||||
});
|
51
node_modules/stylelint-scss/dist/rules/at-mixin-pattern/index.js
generated
vendored
Normal file
51
node_modules/stylelint-scss/dist/rules/at-mixin-pattern/index.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (pattern) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: pattern,
|
||||
possible: [_lodash.isRegExp, _lodash.isString]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var regexpPattern = (0, _lodash.isString)(pattern) ? new RegExp(pattern) : pattern;
|
||||
|
||||
root.walkAtRules(function (decl) {
|
||||
if (decl.name !== "mixin") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stripping the mixin of its arguments
|
||||
var mixinName = decl.params.replace(/(\s*?)\((?:\s|\S)*\)/g, "");
|
||||
if (regexpPattern.test(mixinName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("at-mixin-pattern");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected @mixin name to match specified pattern"
|
||||
});
|
68
node_modules/stylelint-scss/dist/rules/declaration-nested-properties-no-divided-groups/index.js
generated
vendored
Normal file
68
node_modules/stylelint-scss/dist/rules/declaration-nested-properties-no-divided-groups/index.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walk(function (item) {
|
||||
if (item.type !== "rule" && item.type !== "atrule") {
|
||||
return;
|
||||
}
|
||||
|
||||
var nestedGroups = {};
|
||||
|
||||
// Find all nested property groups
|
||||
item.each(function (decl) {
|
||||
if (decl.type !== "rule") {
|
||||
return;
|
||||
}
|
||||
var testForProp = (0, _utils.parseNestedPropRoot)(decl.selector);
|
||||
|
||||
if (testForProp && testForProp.propName !== undefined) {
|
||||
var ns = testForProp.propName.value;
|
||||
if (!nestedGroups.hasOwnProperty(ns)) {
|
||||
nestedGroups[ns] = [];
|
||||
}
|
||||
nestedGroups[ns].push(decl);
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(nestedGroups).forEach(function (namespace) {
|
||||
// Only warn if there are more than one nested groups with equal namespaces
|
||||
if (nestedGroups[namespace].length === 1) {
|
||||
return;
|
||||
}
|
||||
nestedGroups[namespace].forEach(function (group) {
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected(namespace),
|
||||
node: group,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("declaration-nested-properties-no-divided-groups");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: function expected(prop) {
|
||||
return "Expected all nested properties of \"" + prop + "\" namespace to be in one nested group";
|
||||
}
|
||||
});
|
146
node_modules/stylelint-scss/dist/rules/declaration-nested-properties/index.js
generated
vendored
Normal file
146
node_modules/stylelint-scss/dist/rules/declaration-nested-properties/index.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
except: ["only-of-namespace"]
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (expectation === "always") {
|
||||
root.walk(function (item) {
|
||||
if (item.type !== "rule" && item.type !== "atrule") {
|
||||
return;
|
||||
}
|
||||
|
||||
var warningCandidates = {};
|
||||
|
||||
item.each(function (decl) {
|
||||
var prop = decl.prop,
|
||||
type = decl.type,
|
||||
selector = decl.selector;
|
||||
|
||||
// Looking for namespaced non-nested properties
|
||||
// Namespaced prop is basically a prop with a `-` in a name, e.g. `margin-top`
|
||||
|
||||
if (type === "decl") {
|
||||
if (!(0, _utils.isStandardSyntaxProperty)(prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add simple namespaced prop decls to warningCandidates.ns
|
||||
// (prop names with browser prefixes are ignored)
|
||||
var seekNamespace = /^([a-zA-Z0-9]+)-/.exec(prop);
|
||||
if (seekNamespace && seekNamespace[1]) {
|
||||
var ns = seekNamespace[1];
|
||||
if (!warningCandidates.hasOwnProperty(ns)) {
|
||||
warningCandidates[ns] = [];
|
||||
}
|
||||
warningCandidates[ns].push({ node: decl });
|
||||
}
|
||||
}
|
||||
|
||||
// Nested props, `prop: [value] { <nested decls> }`
|
||||
if (type === "rule") {
|
||||
// `background:red {` - selector;
|
||||
// `background: red {` - nested prop; space is decisive here
|
||||
var testForProp = (0, _utils.parseNestedPropRoot)(selector);
|
||||
|
||||
if (testForProp && testForProp.propName !== undefined) {
|
||||
var _ns = testForProp.propName.value;
|
||||
if (!warningCandidates.hasOwnProperty(_ns)) {
|
||||
warningCandidates[_ns] = [];
|
||||
}
|
||||
warningCandidates[_ns].push({
|
||||
node: decl,
|
||||
nested: true
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Now check if the found properties deserve warnings
|
||||
Object.keys(warningCandidates).forEach(function (namespace) {
|
||||
var exceptIfOnlyOfNs = (0, _utils.optionsHaveException)(options, "only-of-namespace");
|
||||
var moreThanOneProp = warningCandidates[namespace].length > 1;
|
||||
|
||||
warningCandidates[namespace].forEach(function (candidate) {
|
||||
if (candidate.nested === true) {
|
||||
if (exceptIfOnlyOfNs) {
|
||||
// If there is only one prop inside a nested prop - warn (reverse "always")
|
||||
if (candidate.nested === true && candidate.node.nodes.length === 1) {
|
||||
_stylelint.utils.report({
|
||||
message: messages.rejected(namespace),
|
||||
node: candidate.node,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Don't warn on non-nested namespaced props if there are
|
||||
// less than 2 of them, and except: "only-of-namespace" is set
|
||||
if (exceptIfOnlyOfNs && !moreThanOneProp) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected(candidate.node.prop),
|
||||
node: candidate.node,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
} else if (expectation === "never") {
|
||||
root.walk(function (item) {
|
||||
// Just check if there are ANY nested props
|
||||
if (item.type === "rule") {
|
||||
// `background:red {` - selector;
|
||||
// `background: red {` - nested prop; space is decisive here
|
||||
var testForProp = (0, _utils.parseNestedPropRoot)(item.selector);
|
||||
|
||||
if (testForProp && testForProp.propName !== undefined) {
|
||||
_stylelint.utils.report({
|
||||
message: messages.rejected(testForProp.propName.value),
|
||||
result: result,
|
||||
ruleName: ruleName,
|
||||
node: item
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("declaration-nested-properties");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: function expected(prop) {
|
||||
return "Expected property \"" + prop + "\" to be in a nested form";
|
||||
},
|
||||
rejected: function rejected(prop) {
|
||||
return "Unexpected nested property \"" + prop + "\"";
|
||||
}
|
||||
});
|
79
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-newline-after/index.js
generated
vendored
Normal file
79
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-newline-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
var checker = (0, _utils.whitespaceChecker)("newline", expectation, messages);
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "always-multi-line"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkDecls(function (decl) {
|
||||
if (!decl.prop || decl.prop[0] !== "$") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the raw $var, and only that
|
||||
var endOfPropIndex = (0, _utils.declarationValueIndex)(decl) + decl.raw("between").length - 1;
|
||||
// `$var:`, `$var :`
|
||||
var propPlusColon = decl.toString().slice(0, endOfPropIndex);
|
||||
|
||||
var _loop = function _loop(i, l) {
|
||||
if (propPlusColon[i] !== ":") {
|
||||
return "continue";
|
||||
}
|
||||
var indexToCheck = propPlusColon.substr(propPlusColon[i], 3) === "/*" ? propPlusColon.indexOf("*/", i) + 1 : i;
|
||||
|
||||
checker.afterOneOnly({
|
||||
source: propPlusColon,
|
||||
index: indexToCheck,
|
||||
lineCheckStr: decl.value,
|
||||
err: function err(m) {
|
||||
_stylelint.utils.report({
|
||||
message: m,
|
||||
node: decl,
|
||||
index: indexToCheck,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
});
|
||||
return "break";
|
||||
};
|
||||
|
||||
_loop2: for (var i = 0, l = propPlusColon.length; i < l; i++) {
|
||||
var _ret = _loop(i, l);
|
||||
|
||||
switch (_ret) {
|
||||
case "continue":
|
||||
continue;
|
||||
|
||||
case "break":
|
||||
break _loop2;}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-colon-newline-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expectedAfter: function expectedAfter() {
|
||||
return "Expected newline after \":\"";
|
||||
},
|
||||
expectedAfterMultiLine: function expectedAfterMultiLine() {
|
||||
return "Expected newline after \":\" with a multi-line value";
|
||||
}
|
||||
});
|
97
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-space-after/index.js
generated
vendored
Normal file
97
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-space-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
var checker = (0, _utils.whitespaceChecker)("space", expectation, messages);
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never", "always-single-line"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
variableColonSpaceChecker({
|
||||
root: root,
|
||||
result: result,
|
||||
locationChecker: checker.after,
|
||||
checkedRuleName: ruleName
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
exports.variableColonSpaceChecker = variableColonSpaceChecker;
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-colon-space-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expectedAfter: function expectedAfter() {
|
||||
return "Expected single space after \":\"";
|
||||
},
|
||||
rejectedAfter: function rejectedAfter() {
|
||||
return "Unexpected whitespace after \":\"";
|
||||
},
|
||||
expectedAfterSingleLine: function expectedAfterSingleLine() {
|
||||
return "Expected single space after \":\" with a single-line value";
|
||||
}
|
||||
});
|
||||
|
||||
function variableColonSpaceChecker(_ref) {
|
||||
var locationChecker = _ref.locationChecker,
|
||||
root = _ref.root,
|
||||
result = _ref.result,
|
||||
checkedRuleName = _ref.checkedRuleName;
|
||||
|
||||
root.walkDecls(function (decl) {
|
||||
|
||||
if (decl.prop === undefined || decl.prop[0] !== "$") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the raw $var, and only that
|
||||
var endOfPropIndex = (0, _utils.declarationValueIndex)(decl) + decl.raw("between").length - 1;
|
||||
// `$var:`, `$var :`
|
||||
var propPlusColon = decl.toString().slice(0, endOfPropIndex);
|
||||
|
||||
var _loop = function _loop(i) {
|
||||
if (propPlusColon[i] !== ":") {
|
||||
return "continue";
|
||||
}
|
||||
locationChecker({
|
||||
source: propPlusColon,
|
||||
index: i,
|
||||
lineCheckStr: decl.value,
|
||||
err: function err(m) {
|
||||
_stylelint.utils.report({
|
||||
message: m,
|
||||
node: decl,
|
||||
index: i,
|
||||
result: result,
|
||||
ruleName: checkedRuleName
|
||||
});
|
||||
}
|
||||
});
|
||||
return "break";
|
||||
};
|
||||
|
||||
_loop2: for (var i = 0; i < propPlusColon.length; i++) {
|
||||
var _ret = _loop(i);
|
||||
|
||||
switch (_ret) {
|
||||
case "continue":
|
||||
continue;
|
||||
|
||||
case "break":
|
||||
break _loop2;}
|
||||
}
|
||||
});
|
||||
}
|
43
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-space-before/index.js
generated
vendored
Normal file
43
node_modules/stylelint-scss/dist/rules/dollar-variable-colon-space-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
var checker = (0, _utils.whitespaceChecker)("space", expectation, messages);
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _dollarVariableColonSpaceAfter.variableColonSpaceChecker)({
|
||||
root: root,
|
||||
result: result,
|
||||
locationChecker: checker.before,
|
||||
checkedRuleName: ruleName
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _dollarVariableColonSpaceAfter = require("../dollar-variable-colon-space-after");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-colon-space-before");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expectedBefore: function expectedBefore() {
|
||||
return "Expected single space before \":\"";
|
||||
},
|
||||
rejectedBefore: function rejectedBefore() {
|
||||
return "Unexpected whitespace before \":\"";
|
||||
}
|
||||
});
|
90
node_modules/stylelint-scss/dist/rules/dollar-variable-empty-line-before/index.js
generated
vendored
Normal file
90
node_modules/stylelint-scss/dist/rules/dollar-variable-empty-line-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
except: ["first-nested", "after-comment", "after-dollar-variable"],
|
||||
ignore: ["after-comment", "inside-single-line-block"]
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkDecls(function (decl) {
|
||||
|
||||
if (!isDollarVar(decl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always ignore the first $var in a stylesheet
|
||||
if (decl === root.first) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If ignoring vars after comments is set
|
||||
if ((0, _utils.optionsHaveIgnored)(options, "after-comment") && decl.prev() && decl.prev().type === "comment") {
|
||||
return;
|
||||
}
|
||||
|
||||
// If ignoring single-line blocks
|
||||
if ((0, _utils.optionsHaveIgnored)(options, "inside-single-line-block") && decl.parent.type !== "root" && (0, _utils.isSingleLineString)((0, _utils.blockString)(decl.parent))) {
|
||||
return;
|
||||
}
|
||||
|
||||
var expectHasEmptyLineBefore = expectation === "always";
|
||||
|
||||
// Reverse for a variable that is a first child of its parent
|
||||
if ((0, _utils.optionsHaveException)(options, "first-nested") && decl === decl.parent.first) {
|
||||
expectHasEmptyLineBefore = !expectHasEmptyLineBefore;
|
||||
}
|
||||
|
||||
// Reverse if after a comment
|
||||
if ((0, _utils.optionsHaveException)(options, "after-comment") && decl.prev() && decl.prev().type === "comment") {
|
||||
expectHasEmptyLineBefore = !expectHasEmptyLineBefore;
|
||||
}
|
||||
|
||||
// Reverse if after another $-variable
|
||||
if ((0, _utils.optionsHaveException)(options, "after-dollar-variable") && decl.prev() && isDollarVar(decl.prev())) {
|
||||
expectHasEmptyLineBefore = !expectHasEmptyLineBefore;
|
||||
}
|
||||
|
||||
if (expectHasEmptyLineBefore === (0, _utils.hasEmptyLine)(decl.raws.before)) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: expectHasEmptyLineBefore ? messages.expected : messages.rejected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-empty-line-before");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected an empty line before $-variable",
|
||||
rejected: "Unxpected empty line before $-variable"
|
||||
});
|
||||
|
||||
function isDollarVar(node) {
|
||||
return node.prop && node.prop[0] === "$";
|
||||
}
|
146
node_modules/stylelint-scss/dist/rules/dollar-variable-no-missing-interpolation/index.js
generated
vendored
Normal file
146
node_modules/stylelint-scss/dist/rules/dollar-variable-no-missing-interpolation/index.js
generated
vendored
Normal file
@@ -0,0 +1,146 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (actual) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual });
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var stringVars = [];
|
||||
var vars = [];
|
||||
|
||||
function findVars(node) {
|
||||
node.walkDecls(function (decl) {
|
||||
var prop = decl.prop,
|
||||
value = decl.value;
|
||||
|
||||
|
||||
if (!isSassVar(prop) || (0, _lodash.includes)(vars, prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isStringVal(value)) {
|
||||
stringVars.push(prop);
|
||||
}
|
||||
|
||||
vars.push(prop);
|
||||
});
|
||||
}
|
||||
|
||||
findVars(root);
|
||||
root.walkRules(findVars);
|
||||
|
||||
if (!vars.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function shouldReport(node, value) {
|
||||
if (isAtSupports(node) || isCustomIdentProp(node)) {
|
||||
return (0, _lodash.includes)(stringVars, value);
|
||||
}
|
||||
if (isCustomIdentAtRule(node)) {
|
||||
return (0, _lodash.includes)(vars, value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function report(node, value) {
|
||||
var name = node.name,
|
||||
prop = node.prop,
|
||||
type = node.type;
|
||||
|
||||
var nodeName = isAtRule(type) ? "@" + name : prop;
|
||||
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: node,
|
||||
message: messages.rejected(nodeName, value)
|
||||
});
|
||||
}
|
||||
|
||||
function exitEarly(node) {
|
||||
return node.type !== "word" || !node.value;
|
||||
}
|
||||
|
||||
function walkValues(node, value) {
|
||||
(0, _postcssValueParser2.default)(value).walk(function (valNode) {
|
||||
var value = valNode.value;
|
||||
|
||||
if (exitEarly(valNode) || !shouldReport(node, value)) {
|
||||
return;
|
||||
}
|
||||
report(node, value);
|
||||
});
|
||||
}
|
||||
|
||||
root.walkDecls(toRegex(customIdentProps), function (decl) {
|
||||
walkValues(decl, decl.value);
|
||||
});
|
||||
|
||||
root.walkAtRules(toRegex(customIdentAtRules), function (atRule) {
|
||||
walkValues(atRule, atRule.params);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _postcssValueParser = require("postcss-value-parser");
|
||||
|
||||
var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-no-missing-interpolation");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: function rejected(n, v) {
|
||||
return "Expected variable " + v + " to be interpolated when using it with " + n;
|
||||
}
|
||||
});
|
||||
|
||||
// https://developer.mozilla.org/en/docs/Web/CSS/custom-ident#Lists_of_excluded_values
|
||||
var customIdentProps = ["animation", "animation-name", "counter-reset", "counter-increment", "list-style-type", "will-change"];
|
||||
|
||||
// https://developer.mozilla.org/en/docs/Web/CSS/At-rule
|
||||
var customIdentAtRules = ["counter-style", "keyframes", "supports"];
|
||||
|
||||
function isAtRule(type) {
|
||||
return type === "atrule";
|
||||
}
|
||||
|
||||
function isCustomIdentAtRule(node) {
|
||||
return isAtRule(node.type) && (0, _lodash.includes)(customIdentAtRules, node.name);
|
||||
}
|
||||
|
||||
function isCustomIdentProp(node) {
|
||||
return (0, _lodash.includes)(customIdentProps, node.prop);
|
||||
}
|
||||
|
||||
function isAtSupports(node) {
|
||||
return isAtRule(node.type) && node.name === "supports";
|
||||
}
|
||||
|
||||
function isSassVar(value) {
|
||||
return value[0] === "$";
|
||||
}
|
||||
|
||||
function isStringVal(value) {
|
||||
return (/^("|').*("|')$/.test(value)
|
||||
);
|
||||
}
|
||||
|
||||
function toRegex(arr) {
|
||||
return new RegExp("(" + arr.join("|") + ")");
|
||||
}
|
61
node_modules/stylelint-scss/dist/rules/dollar-variable-pattern/index.js
generated
vendored
Normal file
61
node_modules/stylelint-scss/dist/rules/dollar-variable-pattern/index.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (pattern, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: pattern,
|
||||
possible: [_lodash.isRegExp, _lodash.isString]
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
ignore: ["local", "global"]
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var regexpPattern = (0, _lodash.isString)(pattern) ? new RegExp(pattern) : pattern;
|
||||
|
||||
root.walkDecls(function (decl) {
|
||||
var prop = decl.prop;
|
||||
|
||||
|
||||
if (prop[0] !== "$") {
|
||||
return;
|
||||
}
|
||||
// If local or global variables need to be ignored
|
||||
if ((0, _utils.optionsHaveIgnored)(options, "global") && decl.parent.type === "root" || (0, _utils.optionsHaveIgnored)(options, "local") && decl.parent.type !== "root") {
|
||||
return;
|
||||
}
|
||||
if (regexpPattern.test(prop.slice(1))) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("dollar-variable-pattern");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected $ variable name to match specified pattern"
|
||||
});
|
91
node_modules/stylelint-scss/dist/rules/double-slash-comment-empty-line-before/index.js
generated
vendored
Normal file
91
node_modules/stylelint-scss/dist/rules/double-slash-comment-empty-line-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
except: ["first-nested"],
|
||||
ignore: ["stylelint-commands", "between-comments"]
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkComments(function (comment) {
|
||||
|
||||
// Only process // comments
|
||||
if (!comment.raws.inline && !comment.inline) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0, _utils.isInlineComment)(comment)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignore the first node
|
||||
if (comment === root.first) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Optionally ignore stylelint commands
|
||||
if (comment.text.indexOf(stylelintCommandPrefix) === 0 && (0, _utils.optionsHaveIgnored)(options, "stylelint-commands")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Optionally ignore newlines between comments
|
||||
var prev = comment.prev();
|
||||
if (prev && prev.type === "comment" && (0, _utils.optionsHaveIgnored)(options, "between-comments")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var before = comment.raw("before");
|
||||
|
||||
var expectEmptyLineBefore = function () {
|
||||
if ((0, _utils.optionsHaveException)(options, "first-nested") && comment.parent !== root && comment === comment.parent.first) {
|
||||
return false;
|
||||
}
|
||||
return expectation === "always";
|
||||
}();
|
||||
|
||||
var hasEmptyLineBefore = before.search(/\n\s*?\n/) !== -1;
|
||||
|
||||
// Return if the expectation is met
|
||||
if (expectEmptyLineBefore === hasEmptyLineBefore) {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = expectEmptyLineBefore ? messages.expected : messages.rejected;
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: message,
|
||||
node: comment,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("double-slash-comment-empty-line-before");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected empty line before comment",
|
||||
rejected: "Unexpected empty line before comment"
|
||||
});
|
||||
|
||||
var stylelintCommandPrefix = "stylelint-";
|
69
node_modules/stylelint-scss/dist/rules/double-slash-comment-inline/index.js
generated
vendored
Normal file
69
node_modules/stylelint-scss/dist/rules/double-slash-comment-inline/index.js
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation, options) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
}, {
|
||||
actual: options,
|
||||
possible: {
|
||||
ignore: ["stylelint-commands"]
|
||||
},
|
||||
optional: true
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var comments = (0, _utils.findCommentsInRaws)(root.source.input.css);
|
||||
comments.forEach(function (comment) {
|
||||
// Only process // comments
|
||||
if (comment.type !== "double-slash") {
|
||||
return;
|
||||
}
|
||||
|
||||
// Optionally ignore stylelint commands
|
||||
if (comment.text.indexOf(stylelintCommandPrefix) === 0 && (0, _utils.optionsHaveIgnored)(options, "stylelint-commands")) {
|
||||
return;
|
||||
}
|
||||
|
||||
var isInline = comment.inlineAfter || comment.inlineBefore;
|
||||
var message = void 0;
|
||||
|
||||
if (isInline && expectation === "never") {
|
||||
message = messages.rejected;
|
||||
} else if (!isInline && expectation === "always") {
|
||||
message = messages.expected;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: message,
|
||||
node: root,
|
||||
index: comment.source.start,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("double-slash-comment-inline");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected //-comment to be inline comment",
|
||||
rejected: "Unexpected inline //-comment"
|
||||
});
|
||||
|
||||
var stylelintCommandPrefix = "stylelint-";
|
60
node_modules/stylelint-scss/dist/rules/double-slash-comment-whitespace-inside/index.js
generated
vendored
Normal file
60
node_modules/stylelint-scss/dist/rules/double-slash-comment-whitespace-inside/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var comments = (0, _utils.findCommentsInRaws)(root.source.input.css);
|
||||
comments.forEach(function (comment) {
|
||||
// Only process // comments
|
||||
if (comment.type !== "double-slash") {
|
||||
return;
|
||||
}
|
||||
// if it's `//` - no warning whatsoever; if `// ` - then trailing
|
||||
// whitespace rule will govern this
|
||||
if (comment.text === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
var message = void 0;
|
||||
|
||||
if (expectation === "never" && comment.raws.left !== "") {
|
||||
message = messages.rejected;
|
||||
} else if (comment.raws.left === "" && expectation === "always") {
|
||||
message = messages.expected;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: message,
|
||||
node: root,
|
||||
index: comment.source.start + comment.raws.startToken.length,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("double-slash-comment-whitespace-inside");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Expected a space after //",
|
||||
rejected: "Unexpected space after //"
|
||||
});
|
170
node_modules/stylelint-scss/dist/rules/index.js
generated
vendored
Normal file
170
node_modules/stylelint-scss/dist/rules/index.js
generated
vendored
Normal file
@@ -0,0 +1,170 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _atExtendNoMissingPlaceholder = require("./at-extend-no-missing-placeholder");
|
||||
|
||||
var _atExtendNoMissingPlaceholder2 = _interopRequireDefault(_atExtendNoMissingPlaceholder);
|
||||
|
||||
var _atElseClosingBraceNewlineAfter = require("./at-else-closing-brace-newline-after");
|
||||
|
||||
var _atElseClosingBraceNewlineAfter2 = _interopRequireDefault(_atElseClosingBraceNewlineAfter);
|
||||
|
||||
var _atElseClosingBraceSpaceAfter = require("./at-else-closing-brace-space-after");
|
||||
|
||||
var _atElseClosingBraceSpaceAfter2 = _interopRequireDefault(_atElseClosingBraceSpaceAfter);
|
||||
|
||||
var _atElseEmptyLineBefore = require("./at-else-empty-line-before");
|
||||
|
||||
var _atElseEmptyLineBefore2 = _interopRequireDefault(_atElseEmptyLineBefore);
|
||||
|
||||
var _atFunctionPattern = require("./at-function-pattern");
|
||||
|
||||
var _atFunctionPattern2 = _interopRequireDefault(_atFunctionPattern);
|
||||
|
||||
var _atIfClosingBraceNewlineAfter = require("./at-if-closing-brace-newline-after");
|
||||
|
||||
var _atIfClosingBraceNewlineAfter2 = _interopRequireDefault(_atIfClosingBraceNewlineAfter);
|
||||
|
||||
var _atIfClosingBraceSpaceAfter = require("./at-if-closing-brace-space-after");
|
||||
|
||||
var _atIfClosingBraceSpaceAfter2 = _interopRequireDefault(_atIfClosingBraceSpaceAfter);
|
||||
|
||||
var _atImportNoPartialExtension = require("./at-import-no-partial-extension");
|
||||
|
||||
var _atImportNoPartialExtension2 = _interopRequireDefault(_atImportNoPartialExtension);
|
||||
|
||||
var _atImportNoPartialLeadingUnderscore = require("./at-import-no-partial-leading-underscore");
|
||||
|
||||
var _atImportNoPartialLeadingUnderscore2 = _interopRequireDefault(_atImportNoPartialLeadingUnderscore);
|
||||
|
||||
var _atImportPartialExtensionBlacklist = require("./at-import-partial-extension-blacklist");
|
||||
|
||||
var _atImportPartialExtensionBlacklist2 = _interopRequireDefault(_atImportPartialExtensionBlacklist);
|
||||
|
||||
var _atImportPartialExtensionWhitelist = require("./at-import-partial-extension-whitelist");
|
||||
|
||||
var _atImportPartialExtensionWhitelist2 = _interopRequireDefault(_atImportPartialExtensionWhitelist);
|
||||
|
||||
var _atMixinArgumentlessCallParentheses = require("./at-mixin-argumentless-call-parentheses");
|
||||
|
||||
var _atMixinArgumentlessCallParentheses2 = _interopRequireDefault(_atMixinArgumentlessCallParentheses);
|
||||
|
||||
var _atMixinNoArgumentlessCallParentheses = require("./at-mixin-no-argumentless-call-parentheses");
|
||||
|
||||
var _atMixinNoArgumentlessCallParentheses2 = _interopRequireDefault(_atMixinNoArgumentlessCallParentheses);
|
||||
|
||||
var _atMixinPattern = require("./at-mixin-pattern");
|
||||
|
||||
var _atMixinPattern2 = _interopRequireDefault(_atMixinPattern);
|
||||
|
||||
var _declarationNestedProperties = require("./declaration-nested-properties");
|
||||
|
||||
var _declarationNestedProperties2 = _interopRequireDefault(_declarationNestedProperties);
|
||||
|
||||
var _declarationNestedPropertiesNoDividedGroups = require("./declaration-nested-properties-no-divided-groups");
|
||||
|
||||
var _declarationNestedPropertiesNoDividedGroups2 = _interopRequireDefault(_declarationNestedPropertiesNoDividedGroups);
|
||||
|
||||
var _dollarVariableColonNewlineAfter = require("./dollar-variable-colon-newline-after");
|
||||
|
||||
var _dollarVariableColonNewlineAfter2 = _interopRequireDefault(_dollarVariableColonNewlineAfter);
|
||||
|
||||
var _dollarVariableColonSpaceAfter = require("./dollar-variable-colon-space-after");
|
||||
|
||||
var _dollarVariableColonSpaceAfter2 = _interopRequireDefault(_dollarVariableColonSpaceAfter);
|
||||
|
||||
var _dollarVariableColonSpaceBefore = require("./dollar-variable-colon-space-before");
|
||||
|
||||
var _dollarVariableColonSpaceBefore2 = _interopRequireDefault(_dollarVariableColonSpaceBefore);
|
||||
|
||||
var _dollarVariableEmptyLineBefore = require("./dollar-variable-empty-line-before");
|
||||
|
||||
var _dollarVariableEmptyLineBefore2 = _interopRequireDefault(_dollarVariableEmptyLineBefore);
|
||||
|
||||
var _dollarVariableNoMissingInterpolation = require("./dollar-variable-no-missing-interpolation");
|
||||
|
||||
var _dollarVariableNoMissingInterpolation2 = _interopRequireDefault(_dollarVariableNoMissingInterpolation);
|
||||
|
||||
var _dollarVariablePattern = require("./dollar-variable-pattern");
|
||||
|
||||
var _dollarVariablePattern2 = _interopRequireDefault(_dollarVariablePattern);
|
||||
|
||||
var _doubleSlashCommentEmptyLineBefore = require("./double-slash-comment-empty-line-before");
|
||||
|
||||
var _doubleSlashCommentEmptyLineBefore2 = _interopRequireDefault(_doubleSlashCommentEmptyLineBefore);
|
||||
|
||||
var _doubleSlashCommentInline = require("./double-slash-comment-inline");
|
||||
|
||||
var _doubleSlashCommentInline2 = _interopRequireDefault(_doubleSlashCommentInline);
|
||||
|
||||
var _doubleSlashCommentWhitespaceInside = require("./double-slash-comment-whitespace-inside");
|
||||
|
||||
var _doubleSlashCommentWhitespaceInside2 = _interopRequireDefault(_doubleSlashCommentWhitespaceInside);
|
||||
|
||||
var _mediaFeatureValueDollarVariable = require("./media-feature-value-dollar-variable");
|
||||
|
||||
var _mediaFeatureValueDollarVariable2 = _interopRequireDefault(_mediaFeatureValueDollarVariable);
|
||||
|
||||
var _operatorNoNewlineAfter = require("./operator-no-newline-after");
|
||||
|
||||
var _operatorNoNewlineAfter2 = _interopRequireDefault(_operatorNoNewlineAfter);
|
||||
|
||||
var _operatorNoNewlineBefore = require("./operator-no-newline-before");
|
||||
|
||||
var _operatorNoNewlineBefore2 = _interopRequireDefault(_operatorNoNewlineBefore);
|
||||
|
||||
var _operatorNoUnspaced = require("./operator-no-unspaced");
|
||||
|
||||
var _operatorNoUnspaced2 = _interopRequireDefault(_operatorNoUnspaced);
|
||||
|
||||
var _partialNoImport = require("./partial-no-import");
|
||||
|
||||
var _partialNoImport2 = _interopRequireDefault(_partialNoImport);
|
||||
|
||||
var _percentPlaceholderPattern = require("./percent-placeholder-pattern");
|
||||
|
||||
var _percentPlaceholderPattern2 = _interopRequireDefault(_percentPlaceholderPattern);
|
||||
|
||||
var _selectorNoRedundantNestingSelector = require("./selector-no-redundant-nesting-selector");
|
||||
|
||||
var _selectorNoRedundantNestingSelector2 = _interopRequireDefault(_selectorNoRedundantNestingSelector);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.default = {
|
||||
"at-extend-no-missing-placeholder": _atExtendNoMissingPlaceholder2.default,
|
||||
"at-else-closing-brace-newline-after": _atElseClosingBraceNewlineAfter2.default,
|
||||
"at-else-closing-brace-space-after": _atElseClosingBraceSpaceAfter2.default,
|
||||
"at-else-empty-line-before": _atElseEmptyLineBefore2.default,
|
||||
"at-function-pattern": _atFunctionPattern2.default,
|
||||
"at-if-closing-brace-newline-after": _atIfClosingBraceNewlineAfter2.default,
|
||||
"at-if-closing-brace-space-after": _atIfClosingBraceSpaceAfter2.default,
|
||||
"at-import-no-partial-extension": _atImportNoPartialExtension2.default,
|
||||
"at-import-no-partial-leading-underscore": _atImportNoPartialLeadingUnderscore2.default,
|
||||
"at-import-partial-extension-blacklist": _atImportPartialExtensionBlacklist2.default,
|
||||
"at-import-partial-extension-whitelist": _atImportPartialExtensionWhitelist2.default,
|
||||
"at-mixin-argumentless-call-parentheses": _atMixinArgumentlessCallParentheses2.default,
|
||||
"at-mixin-no-argumentless-call-parentheses": _atMixinNoArgumentlessCallParentheses2.default,
|
||||
"at-mixin-pattern": _atMixinPattern2.default,
|
||||
"declaration-nested-properties": _declarationNestedProperties2.default,
|
||||
"declaration-nested-properties-no-divided-groups": _declarationNestedPropertiesNoDividedGroups2.default,
|
||||
"dollar-variable-colon-newline-after": _dollarVariableColonNewlineAfter2.default,
|
||||
"dollar-variable-colon-space-after": _dollarVariableColonSpaceAfter2.default,
|
||||
"dollar-variable-colon-space-before": _dollarVariableColonSpaceBefore2.default,
|
||||
"dollar-variable-empty-line-before": _dollarVariableEmptyLineBefore2.default,
|
||||
"dollar-variable-no-missing-interpolation": _dollarVariableNoMissingInterpolation2.default,
|
||||
"dollar-variable-pattern": _dollarVariablePattern2.default,
|
||||
"double-slash-comment-empty-line-before": _doubleSlashCommentEmptyLineBefore2.default,
|
||||
"double-slash-comment-inline": _doubleSlashCommentInline2.default,
|
||||
"double-slash-comment-whitespace-inside": _doubleSlashCommentWhitespaceInside2.default,
|
||||
"media-feature-value-dollar-variable": _mediaFeatureValueDollarVariable2.default,
|
||||
"operator-no-newline-after": _operatorNoNewlineAfter2.default,
|
||||
"operator-no-newline-before": _operatorNoNewlineBefore2.default,
|
||||
"operator-no-unspaced": _operatorNoUnspaced2.default,
|
||||
"percent-placeholder-pattern": _percentPlaceholderPattern2.default,
|
||||
"partial-no-import": _partialNoImport2.default,
|
||||
"selector-no-redundant-nesting-selector": _selectorNoRedundantNestingSelector2.default
|
||||
};
|
71
node_modules/stylelint-scss/dist/rules/media-feature-value-dollar-variable/index.js
generated
vendored
Normal file
71
node_modules/stylelint-scss/dist/rules/media-feature-value-dollar-variable/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation,
|
||||
possible: ["always", "never"]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var valueRegex = /:(?:\s*?)(\S.+?)(:?\s*?)\)/;
|
||||
// In `(max-width: 10px )` find `: 10px )`.
|
||||
// Got to go with that (the global search doesn't remember parens' insides)
|
||||
// and parse it again afterwards to remove trailing junk
|
||||
var valueRegexGlobal = new RegExp(valueRegex.source, "g");
|
||||
// `$var-name_sth`
|
||||
var variableRegex = /^\$[A-Za-z_0-9-]+$/;
|
||||
// `#{$var-name_sth}`
|
||||
var interpolationVarRegex = /^#\{\s*?\$[A-Za-z_0-9]+\s*?\}$/;
|
||||
|
||||
root.walkAtRules("media", function (atRule) {
|
||||
var found = atRule.params.match(valueRegexGlobal);
|
||||
// If there are no values
|
||||
if (!found || !found.length) {
|
||||
return;
|
||||
}
|
||||
found.forEach(function (found) {
|
||||
// ... parse `: 10px )` to `10px`
|
||||
var valueParsed = found.match(valueRegex)[1];
|
||||
|
||||
// Just a shorthand to stylelint.utils.report()
|
||||
function complain(message) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: atRule,
|
||||
word: valueParsed,
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
// A value should be a single variable
|
||||
// or it should be a single variable inside Sass interpolation
|
||||
if (expectation === "always" && !(valueParsed.search(variableRegex) !== -1 || valueParsed.search(interpolationVarRegex) !== -1)) {
|
||||
complain(messages.expected);
|
||||
} else if (expectation === "never" && valueParsed.indexOf("$") !== -1) {
|
||||
// "Never" means no variables at all (functions allowed)
|
||||
complain(messages.rejected);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("media-feature-value-dollar-variable");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: "Unexpected dollar-variable as a media feature value",
|
||||
expected: "Expected a dollar-variable (e.g. $var) to be used as a media feature value"
|
||||
});
|
71
node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
generated
vendored
Normal file
71
node_modules/stylelint-scss/dist/rules/operator-no-newline-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _operatorNoUnspaced.calculationOperatorSpaceChecker)({
|
||||
root: root,
|
||||
result: result,
|
||||
checker: checkNewlineBefore
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _operatorNoUnspaced = require("../operator-no-unspaced");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("operator-no-newline-after");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: function rejected(operator) {
|
||||
return "Unexpected newline after \"" + operator + "\"";
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The checker function: whether there is a newline before THAT operator.
|
||||
*/
|
||||
function checkNewlineBefore(_ref) {
|
||||
var string = _ref.string,
|
||||
globalIndex = _ref.globalIndex,
|
||||
startIndex = _ref.startIndex,
|
||||
endIndex = _ref.endIndex,
|
||||
node = _ref.node,
|
||||
result = _ref.result;
|
||||
|
||||
var symbol = string.substring(startIndex, endIndex + 1);
|
||||
var newLineBefore = false;
|
||||
|
||||
var index = endIndex + 1;
|
||||
while (index && (0, _utils.isWhitespace)(string[index])) {
|
||||
if (string[index] === "\n") {
|
||||
newLineBefore = true;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (newLineBefore) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: node,
|
||||
message: messages.rejected(symbol),
|
||||
index: endIndex + globalIndex
|
||||
});
|
||||
}
|
||||
}
|
71
node_modules/stylelint-scss/dist/rules/operator-no-newline-before/index.js
generated
vendored
Normal file
71
node_modules/stylelint-scss/dist/rules/operator-no-newline-before/index.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
(0, _operatorNoUnspaced.calculationOperatorSpaceChecker)({
|
||||
root: root,
|
||||
result: result,
|
||||
checker: checkNewlineBefore
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _operatorNoUnspaced = require("../operator-no-unspaced");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("operator-no-newline-before");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: function rejected(operator) {
|
||||
return "Unexpected newline before \"" + operator + "\"";
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The checker function: whether there is a newline before THAT operator.
|
||||
*/
|
||||
function checkNewlineBefore(_ref) {
|
||||
var string = _ref.string,
|
||||
globalIndex = _ref.globalIndex,
|
||||
startIndex = _ref.startIndex,
|
||||
endIndex = _ref.endIndex,
|
||||
node = _ref.node,
|
||||
result = _ref.result;
|
||||
|
||||
var symbol = string.substring(startIndex, endIndex + 1);
|
||||
var newLineBefore = false;
|
||||
|
||||
var index = startIndex - 1;
|
||||
while (index && (0, _utils.isWhitespace)(string[index])) {
|
||||
if (string[index] === "\n") {
|
||||
newLineBefore = true;
|
||||
break;
|
||||
}
|
||||
index--;
|
||||
}
|
||||
|
||||
if (newLineBefore) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: node,
|
||||
message: messages.rejected(symbol),
|
||||
index: endIndex + globalIndex
|
||||
});
|
||||
}
|
||||
}
|
243
node_modules/stylelint-scss/dist/rules/operator-no-unspaced/index.js
generated
vendored
Normal file
243
node_modules/stylelint-scss/dist/rules/operator-no-unspaced/index.js
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (expectation) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: expectation
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
calculationOperatorSpaceChecker({
|
||||
root: root,
|
||||
result: result,
|
||||
checker: checkSpaces
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
exports.calculationOperatorSpaceChecker = calculationOperatorSpaceChecker;
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _postcssMediaQueryParser = require("postcss-media-query-parser");
|
||||
|
||||
var _postcssMediaQueryParser2 = _interopRequireDefault(_postcssMediaQueryParser);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("operator-no-unspaced");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expectedAfter: function expectedAfter(operator) {
|
||||
return "Expected single space after \"" + operator + "\"";
|
||||
},
|
||||
expectedBefore: function expectedBefore(operator) {
|
||||
return "Expected single space before \"" + operator + "\"";
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* The actual check for are there (un)necessary whitespaces
|
||||
*/
|
||||
function checkSpaces(_ref) {
|
||||
var string = _ref.string,
|
||||
globalIndex = _ref.globalIndex,
|
||||
startIndex = _ref.startIndex,
|
||||
endIndex = _ref.endIndex,
|
||||
node = _ref.node,
|
||||
result = _ref.result;
|
||||
|
||||
var symbol = string.substring(startIndex, endIndex + 1);
|
||||
|
||||
var beforeOk = string[startIndex - 1] === " " && !(0, _utils.isWhitespace)(string[startIndex - 2]) || newlineBefore(string, startIndex - 1);
|
||||
if (!beforeOk) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: node,
|
||||
message: messages.expectedBefore(symbol),
|
||||
index: startIndex + globalIndex
|
||||
});
|
||||
}
|
||||
|
||||
var afterOk = string[endIndex + 1] === " " && !(0, _utils.isWhitespace)(string[endIndex + 2]) || string[endIndex + 1] === "\n" || string.substr(endIndex + 1, 2) === "\r\n";
|
||||
|
||||
if (!afterOk) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: node,
|
||||
message: messages.expectedAfter(symbol),
|
||||
index: endIndex + globalIndex
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function newlineBefore(str, startIndex) {
|
||||
var index = startIndex;
|
||||
while (index && (0, _utils.isWhitespace)(str[index])) {
|
||||
if (str[index] === "\n") return true;
|
||||
index--;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* The core rule logic function. This one can be imported by some other rules
|
||||
* that work with Sass operators
|
||||
*
|
||||
* @param {Object} args -- Named arguments object
|
||||
* @param {PostCSS Root} args.root
|
||||
* @param {PostCSS Result} args.result
|
||||
* @param {function} args.checker -- the function that is run against all the
|
||||
* operators found in the input. Takes these arguments:
|
||||
* {Object} cbArgs -- Named arguments object
|
||||
* {string} cbArgs.string -- the input string (suspected operation)
|
||||
* {number} cbArgs.globalIndex -- the string's index in a global input
|
||||
* {number} cbArgs.startIndex -- the start index of a sybmol to inspect
|
||||
* {number} cbArgs.endIndex -- the end index of a sybmol to inspect
|
||||
* (two indexes needed to allow for `==`, `!=`, etc.)
|
||||
* {PostCSS Node} cbArgs.node -- for stylelint.utils.report
|
||||
* {PostCSS Result} cbArgs.result -- for stylelint.utils.report
|
||||
*/
|
||||
function calculationOperatorSpaceChecker(_ref2) {
|
||||
var root = _ref2.root,
|
||||
result = _ref2.result,
|
||||
checker = _ref2.checker;
|
||||
|
||||
|
||||
/**
|
||||
* Takes a string, finds all occurencies of Sass interpolaion in it, then
|
||||
* finds all operators inside that interpolation
|
||||
*
|
||||
* @return {array} An array of ojbects { string, operators } - effectively,
|
||||
* a list of operators for each Sass interpolation occurence
|
||||
*/
|
||||
function findInterpolation(string, startIndex) {
|
||||
var interpolationRegex = /#{(.*?)}/g;
|
||||
var results = [];
|
||||
// Searching for interpolation
|
||||
var match = interpolationRegex.exec(string);
|
||||
startIndex = !isNaN(startIndex) ? Number(startIndex) : 0;
|
||||
while (match !== null) {
|
||||
results.push({
|
||||
source: match[0],
|
||||
operators: (0, _utils.findOperators)({
|
||||
string: match[0],
|
||||
globalIndex: match.index + startIndex
|
||||
})
|
||||
});
|
||||
match = interpolationRegex.exec(string);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
root.walk(function (item) {
|
||||
var results = [];
|
||||
|
||||
// Check a value (`10px` in `width: 10px;`)
|
||||
if (item.value !== undefined) {
|
||||
results.push({
|
||||
source: item.value,
|
||||
operators: (0, _utils.findOperators)({
|
||||
string: item.value,
|
||||
globalIndex: (0, _utils.declarationValueIndex)(item),
|
||||
// For Sass variable values some special rules apply
|
||||
isAfterColon: item.prop[0] === "$"
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// Property name
|
||||
if (item.prop !== undefined) {
|
||||
results = results.concat(findInterpolation(item.prop));
|
||||
}
|
||||
// Selector
|
||||
if (item.selector !== undefined) {
|
||||
results = results.concat(findInterpolation(item.selector));
|
||||
}
|
||||
|
||||
if (item.type === "atrule") {
|
||||
|
||||
// Media queries
|
||||
if (item.name === "media" || item.name === "import") {
|
||||
(0, _postcssMediaQueryParser2.default)(item.params).walk(function (node) {
|
||||
var type = node.type;
|
||||
if (["keyword", "media-type", "media-feature"].indexOf(type) !== -1) {
|
||||
results = results.concat(findInterpolation(node.value, (0, _utils.atRuleParamIndex)(item) + node.sourceIndex));
|
||||
} else if (["value", "url"].indexOf(type) !== -1) {
|
||||
results.push({
|
||||
source: node.value,
|
||||
operators: (0, _utils.findOperators)({
|
||||
string: node.value,
|
||||
globalIndex: (0, _utils.atRuleParamIndex)(item) + node.sourceIndex,
|
||||
isAfterColon: true
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Function and mixin definitions and other rules
|
||||
results.push({
|
||||
source: item.params,
|
||||
operators: (0, _utils.findOperators)({
|
||||
string: item.params,
|
||||
globalIndex: (0, _utils.atRuleParamIndex)(item),
|
||||
isAfterColon: true
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// All the strings have been parsed, now run whitespace checking
|
||||
results.forEach(function (el) {
|
||||
// Only if there are operators within a string
|
||||
if (el.operators && el.operators.length > 0) {
|
||||
el.operators.forEach(function (operator) {
|
||||
checker({
|
||||
string: el.source,
|
||||
globalIndex: operator.globalIndex,
|
||||
startIndex: operator.startIndex,
|
||||
endIndex: operator.endIndex,
|
||||
node: item,
|
||||
result: result
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Checking interpolation inside comments
|
||||
// We have to give up on PostCSS here because it skips some inline comments
|
||||
(0, _utils.findCommentsInRaws)(root.source.input.css).forEach(function (comment) {
|
||||
var startIndex = comment.source.start + comment.raws.startToken.length + comment.raws.left.length;
|
||||
if (comment.type !== "css") {
|
||||
return;
|
||||
}
|
||||
|
||||
findInterpolation(comment.text).forEach(function (el) {
|
||||
// Only if there are operators within a string
|
||||
if (el.operators && el.operators.length > 0) {
|
||||
el.operators.forEach(function (operator) {
|
||||
checker({
|
||||
string: el.source,
|
||||
globalIndex: operator.globalIndex + startIndex,
|
||||
startIndex: operator.startIndex,
|
||||
endIndex: operator.endIndex,
|
||||
node: root,
|
||||
result: result
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
75
node_modules/stylelint-scss/dist/rules/partial-no-import/index.js
generated
vendored
Normal file
75
node_modules/stylelint-scss/dist/rules/partial-no-import/index.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (on) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: on
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (root.source.input.file === undefined || !root.source.input.file) {
|
||||
result.warn("The 'partial-no-import' rule won't work if linting in a code string without an actual file.");
|
||||
return;
|
||||
}
|
||||
|
||||
var fileName = _path2.default.basename(root.source.input.file);
|
||||
var extName = _path2.default.extname(root.source.input.file);
|
||||
|
||||
function checkImportForCSS(path, decl) {
|
||||
// Stripping trailing quotes and whitespaces, if any
|
||||
var pathStripped = path.replace(/^\s*?("|')\s*/, "").replace(/\s*("|')\s*?$/, "");
|
||||
|
||||
// Skipping importing CSS: url(), ".css", URI with a protocol, media
|
||||
if (pathStripped.slice(0, 4) === "url(" || pathStripped.slice(-4) === ".css" || pathStripped.search("//") !== -1 || pathStripped.search(/(?:\s|[,)"'])\w+$/) !== -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
_stylelint.utils.report({
|
||||
message: messages.expected,
|
||||
node: decl,
|
||||
result: result,
|
||||
ruleName: ruleName
|
||||
});
|
||||
}
|
||||
|
||||
// Usual CSS file
|
||||
if (extName === ".css") {
|
||||
return;
|
||||
}
|
||||
// Not a partial
|
||||
if (fileName[0] !== "_") {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkAtRules("import", function (mixinCall) {
|
||||
// Check if @import is treated as CSS import; report only if not
|
||||
// Processing comma-separated lists of import paths
|
||||
mixinCall.params.split(",").forEach(function (path) {
|
||||
checkImportForCSS(path, mixinCall);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var _path2 = _interopRequireDefault(_path);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("partial-no-import");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: "Unexpected @import in a partial"
|
||||
});
|
96
node_modules/stylelint-scss/dist/rules/percent-placeholder-pattern/index.js
generated
vendored
Normal file
96
node_modules/stylelint-scss/dist/rules/percent-placeholder-pattern/index.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (pattern) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, {
|
||||
actual: pattern,
|
||||
possible: [_lodash.isRegExp, _lodash.isString]
|
||||
});
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
var placeholderPattern = (0, _lodash.isString)(pattern) ? new RegExp(pattern) : pattern;
|
||||
|
||||
// Checking placeholder definitions (looking among regular rules)
|
||||
root.walkRules(function (rule) {
|
||||
var selector = rule.selector;
|
||||
// Just a shorthand for calling `parseSelector`
|
||||
|
||||
function parse(selector) {
|
||||
(0, _utils.parseSelector)(selector, result, rule, function (s) {
|
||||
return checkSelector(s, rule);
|
||||
});
|
||||
}
|
||||
|
||||
// If it's a custom prop or a less mixin
|
||||
if (!(0, _utils.isStandardRule)(rule)) {
|
||||
return;
|
||||
}
|
||||
// If the selector has interpolation
|
||||
if (!(0, _utils.isStandardSelector)(selector)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Nested selectors are processed in steps, as nesting levels are resolved.
|
||||
// Here we skip processing intermediate parts of selectors (to process only fully resolved selectors)
|
||||
// if (rule.nodes.some(node => node.type === "rule" || node.type === "atrule")) { return }
|
||||
|
||||
// Only resolve selectors that have an interpolating "&"
|
||||
if ((0, _utils.hasInterpolatingAmpersand)(selector)) {
|
||||
(0, _postcssResolveNestedSelector2.default)(selector, rule).forEach(parse);
|
||||
} else {
|
||||
parse(selector);
|
||||
}
|
||||
});
|
||||
|
||||
function checkSelector(fullSelector, rule) {
|
||||
// postcss-selector-parser gives %placeholders' nodes a "tag" type
|
||||
fullSelector.walkTags(function (compoundSelector) {
|
||||
var value = compoundSelector.value,
|
||||
sourceIndex = compoundSelector.sourceIndex;
|
||||
|
||||
if (value[0] !== "%") {
|
||||
return;
|
||||
}
|
||||
var placeholder = value.slice(1);
|
||||
|
||||
if (placeholderPattern.test(placeholder)) {
|
||||
return;
|
||||
}
|
||||
_stylelint.utils.report({
|
||||
result: result,
|
||||
ruleName: ruleName,
|
||||
message: messages.expected(placeholder),
|
||||
node: rule,
|
||||
index: sourceIndex
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _postcssResolveNestedSelector = require("postcss-resolve-nested-selector");
|
||||
|
||||
var _postcssResolveNestedSelector2 = _interopRequireDefault(_postcssResolveNestedSelector);
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("percent-placeholder-pattern");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
expected: function expected(placeholder) {
|
||||
return "Expected %-placeholder \"%" + placeholder + "\" to match specified pattern";
|
||||
}
|
||||
});
|
41
node_modules/stylelint-scss/dist/rules/selector-no-redundant-nesting-selector/index.js
generated
vendored
Normal file
41
node_modules/stylelint-scss/dist/rules/selector-no-redundant-nesting-selector/index.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.messages = exports.ruleName = undefined;
|
||||
|
||||
exports.default = function (actual) {
|
||||
return function (root, result) {
|
||||
var validOptions = _stylelint.utils.validateOptions(result, ruleName, { actual: actual });
|
||||
if (!validOptions) {
|
||||
return;
|
||||
}
|
||||
|
||||
root.walkRules(/&/, function (rule) {
|
||||
var selector = rule.selector;
|
||||
// "Ampersand followed by a combinator followed by non-combinator non-ampersand and not the selector end"
|
||||
|
||||
var regex = /^&\s*[>+~ ]\s*[^>+~ {&]+/;
|
||||
|
||||
if (selector === "&" || regex.test(selector)) {
|
||||
_stylelint.utils.report({
|
||||
ruleName: ruleName,
|
||||
result: result,
|
||||
node: rule,
|
||||
message: messages.rejected
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
var _stylelint = require("stylelint");
|
||||
|
||||
var _utils = require("../../utils");
|
||||
|
||||
var ruleName = exports.ruleName = (0, _utils.namespace)("selector-no-redundant-nesting-selector");
|
||||
|
||||
var messages = exports.messages = _stylelint.utils.ruleMessages(ruleName, {
|
||||
rejected: "Unnecessary nesting selector (&)"
|
||||
});
|
14
node_modules/stylelint-scss/dist/utils/atRuleParamIndex.js
generated
vendored
Normal file
14
node_modules/stylelint-scss/dist/utils/atRuleParamIndex.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (atRule) {
|
||||
// Initial 1 is for the `@`
|
||||
var index = 1 + atRule.name.length;
|
||||
if (atRule.raw("afterName")) {
|
||||
index += atRule.raw("afterName").length;
|
||||
}
|
||||
return index;
|
||||
};
|
32
node_modules/stylelint-scss/dist/utils/beforeBlockString.js
generated
vendored
Normal file
32
node_modules/stylelint-scss/dist/utils/beforeBlockString.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (statement) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
noRawBefore = _ref.noRawBefore;
|
||||
|
||||
var result = "";
|
||||
if (statement.type !== "rule" && statement.type !== "atrule") {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!noRawBefore) {
|
||||
result += statement.raws.before;
|
||||
}
|
||||
if (statement.type === "rule") {
|
||||
result += statement.selector;
|
||||
} else {
|
||||
result += "@" + statement.name + statement.raws.afterName + statement.params;
|
||||
}
|
||||
|
||||
var between = statement.raws.between;
|
||||
|
||||
if (between !== undefined) {
|
||||
result += between;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
26
node_modules/stylelint-scss/dist/utils/blockString.js
generated
vendored
Normal file
26
node_modules/stylelint-scss/dist/utils/blockString.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (statement) {
|
||||
if (!(0, _hasBlock2.default)(statement)) {
|
||||
return;
|
||||
}
|
||||
return (0, _rawNodeString2.default)(statement).slice((0, _beforeBlockString2.default)(statement).length);
|
||||
};
|
||||
|
||||
var _beforeBlockString = require("./beforeBlockString");
|
||||
|
||||
var _beforeBlockString2 = _interopRequireDefault(_beforeBlockString);
|
||||
|
||||
var _hasBlock = require("./hasBlock");
|
||||
|
||||
var _hasBlock2 = _interopRequireDefault(_hasBlock);
|
||||
|
||||
var _rawNodeString = require("./rawNodeString");
|
||||
|
||||
var _rawNodeString2 = _interopRequireDefault(_rawNodeString);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
node_modules/stylelint-scss/dist/utils/configurationError.js
generated
vendored
Normal file
11
node_modules/stylelint-scss/dist/utils/configurationError.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (text) {
|
||||
var err = new Error(text);
|
||||
err.code = 78;
|
||||
return err;
|
||||
};
|
11
node_modules/stylelint-scss/dist/utils/declarationValueIndex.js
generated
vendored
Normal file
11
node_modules/stylelint-scss/dist/utils/declarationValueIndex.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (decl) {
|
||||
var beforeColon = decl.toString().indexOf(":");
|
||||
var afterColon = decl.raw("between").length - decl.raw("between").indexOf(":");
|
||||
return beforeColon + afterColon;
|
||||
};
|
218
node_modules/stylelint-scss/dist/utils/findCommentsInRaws.js
generated
vendored
Normal file
218
node_modules/stylelint-scss/dist/utils/findCommentsInRaws.js
generated
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = findCommentsInRaws;
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/**
|
||||
* Finds comments, both CSS comments and double slash ones, in a CSS string
|
||||
* This helper exists because PostCSS drops some inline comments (those
|
||||
* between seelctors, property values, etc.)
|
||||
* https://github.com/postcss/postcss/issues/845#issuecomment-232306259
|
||||
*
|
||||
* @param [string] rawString -- the source raw CSS string
|
||||
* @return [array] array of objects with these props:
|
||||
* <20> type -- "css" or "double-slash"
|
||||
* <20> source: { start, end }
|
||||
* IMPORTANT: the function itself considers \r as a character, and counts
|
||||
* it for `start` and `end`. But if their values are passed to PostCSS's
|
||||
* result.warn(), than "\r\n" is consideren ONE CHAR (newline)!
|
||||
* <20> raws
|
||||
* raws.startToken -- `/*`, `/**`, `/**!`, etc.
|
||||
* raws.left -- whitespace after the comment opening marker
|
||||
* raws.text -- the full comment, including markers (//, /*)
|
||||
* raws.right -- whitespace before the comment closing marker
|
||||
* raws.endToken -- `*\/`, `**\/` for CSS comments
|
||||
* <20> text -- the comment text only, excluding //, /*, trailing whitespaces
|
||||
* <20> inlineAfter -- true, if there is something before the comment on
|
||||
* the same line
|
||||
* <20> inlineBefore -- true, if there is something after the comment on
|
||||
* the same line
|
||||
*/
|
||||
|
||||
function findCommentsInRaws(rawString) {
|
||||
var result = [];
|
||||
var comment = {};
|
||||
// Keeps track of which structure the parser is inside (string, comment,
|
||||
// url function, parens). E.g., /* comment */ inside a string doesn't
|
||||
// constitute a comment, so as url(//path)
|
||||
var modesEntered = [{
|
||||
mode: "normal",
|
||||
character: null
|
||||
}];
|
||||
var commentStart = null;
|
||||
|
||||
// postcss-scss transforms //-comments into CSS comments, like so:
|
||||
// `// comment` -> `/* comment*/`. So to have a correct intex we need to
|
||||
// keep track on the added `*/` sequences
|
||||
var offset = 0;
|
||||
|
||||
for (var i = 0; i < rawString.length; i++) {
|
||||
var character = rawString[i];
|
||||
var prevChar = i > 0 ? rawString[i - 1] : null;
|
||||
var nextChar = i + 1 < rawString.length ? rawString[i + 1] : null;
|
||||
|
||||
var lastModeIndex = modesEntered.length - 1;
|
||||
var mode = modesEntered[lastModeIndex].mode;
|
||||
|
||||
switch (character) {
|
||||
// If entering/exiting a string
|
||||
case "\"":
|
||||
case "'":
|
||||
{
|
||||
if (mode === "comment") {
|
||||
break;
|
||||
}
|
||||
if (mode === "string" && modesEntered[lastModeIndex].character === character && prevChar !== "\\") {
|
||||
// Exiting a string
|
||||
modesEntered.pop();
|
||||
} else {
|
||||
// Entering a string
|
||||
modesEntered.push({
|
||||
mode: "string",
|
||||
character: character
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Entering url, other function or parens (only url matters)
|
||||
case "(":
|
||||
{
|
||||
if (mode === "comment" || mode === "string") {
|
||||
break;
|
||||
}
|
||||
var functionNameRegSearch = /(?:^|(?:\n)|(?:\r)|(?:\s-)|[:\s,.(){}*+/%])([a-zA-Z0-9_-]*)$/.exec(rawString.substring(0, i));
|
||||
// A `\S(` can be in, say, `@media(`
|
||||
if (!functionNameRegSearch) {
|
||||
modesEntered.push({
|
||||
mode: "parens",
|
||||
character: "("
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
var functionName = functionNameRegSearch[1];
|
||||
modesEntered.push({
|
||||
mode: functionName === "url" ? "url" : "parens",
|
||||
character: "("
|
||||
});
|
||||
break;
|
||||
}
|
||||
// Exiting url, other function or parens
|
||||
case ")":
|
||||
{
|
||||
if (mode === "comment" || mode === "string") {
|
||||
break;
|
||||
}
|
||||
modesEntered.pop();
|
||||
break;
|
||||
}
|
||||
// checking for comment
|
||||
case "/":
|
||||
{
|
||||
// Break if the / is inside a comment because we leap over the second
|
||||
// slash in // and in */, so the / is not from a marker. Also break
|
||||
// if inside a string
|
||||
if (mode === "comment" || mode === "string") {
|
||||
break;
|
||||
}
|
||||
if (nextChar === "*") {
|
||||
modesEntered.push({
|
||||
mode: "comment",
|
||||
character: "/*"
|
||||
});
|
||||
comment = {
|
||||
type: "css",
|
||||
source: { start: i + offset },
|
||||
// If i is 0 then the file/the line starts with this comment
|
||||
inlineAfter: i > 0 && rawString.substring(0, i).search(/\n\s*$/) === -1
|
||||
};
|
||||
commentStart = i;
|
||||
// Skip the next iteration as the * is already checked
|
||||
i++;
|
||||
} else if (nextChar === "/") {
|
||||
// `url(//path/to/file)` has no comment
|
||||
if (mode === "url") {
|
||||
break;
|
||||
}
|
||||
modesEntered.push({
|
||||
mode: "comment",
|
||||
character: "//"
|
||||
});
|
||||
comment = {
|
||||
type: "double-slash",
|
||||
source: { start: i + offset },
|
||||
// If i is 0 then the file/the line starts with this comment
|
||||
inlineAfter: i > 0 && rawString.substring(0, i).search(/\n\s*$/) === -1
|
||||
};
|
||||
commentStart = i;
|
||||
// Skip the next iteration as the second slash in // is already checked
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Might be a closing `*/`
|
||||
case "*":
|
||||
{
|
||||
if (mode === "comment" && modesEntered[lastModeIndex].character === "/*" && nextChar === "/") {
|
||||
comment.source.end = i + 1 + offset;
|
||||
|
||||
var commentRaw = rawString.substring(commentStart, i + 2);
|
||||
var matches = /^(\/\*+[!#]{0,1})(\s*)([\s\S]*?)(\s*?)(\*+\/)$/.exec(commentRaw);
|
||||
modesEntered.pop();
|
||||
comment.raws = {
|
||||
startToken: matches[1],
|
||||
left: matches[2],
|
||||
text: commentRaw,
|
||||
right: matches[4],
|
||||
endToken: matches[5]
|
||||
};
|
||||
comment.text = matches[3];
|
||||
comment.inlineBefore = rawString.substring(i + 2).search(/^\s*?\S+\s*?\n/) !== -1;
|
||||
result.push(_lodash2.default.assign({}, comment));
|
||||
comment = {};
|
||||
// Skip the next loop as the / in */ is already checked
|
||||
i++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
var isNewline = character === "\r" && rawString[i + 1] === "\n" || character === "\n" && rawString[i - 1] !== "\r";
|
||||
// //-comments end before newline and if the code string ends
|
||||
if (isNewline || i === rawString.length - 1) {
|
||||
if (mode === "comment" && modesEntered[lastModeIndex].character === "//") {
|
||||
comment.source.end = (isNewline ? i - 1 : i) + offset;
|
||||
|
||||
var _commentRaw = rawString.substring(commentStart, isNewline ? i : i + 1);
|
||||
var _matches = /^(\/+)(\s*)(.*?)(\s*?)$/.exec(_commentRaw);
|
||||
|
||||
modesEntered.pop();
|
||||
comment.raws = {
|
||||
startToken: _matches[1],
|
||||
left: _matches[2],
|
||||
text: _commentRaw,
|
||||
right: _matches[4]
|
||||
};
|
||||
comment.text = _matches[3];
|
||||
comment.inlineBefore = false;
|
||||
result.push(_lodash2.default.assign({}, comment));
|
||||
comment = {};
|
||||
// Compensate for the `*/` added by postcss-scss
|
||||
offset += 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
9
node_modules/stylelint-scss/dist/utils/hasBlock.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/hasBlock.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (statement) {
|
||||
return statement.nodes !== undefined;
|
||||
};
|
9
node_modules/stylelint-scss/dist/utils/hasEmptyLine.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/hasEmptyLine.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (string) {
|
||||
return string && (string.indexOf("\n\n") !== -1 || string.indexOf("\n\r\n") !== -1);
|
||||
};
|
41
node_modules/stylelint-scss/dist/utils/hasInterpolatingAmpersand.js
generated
vendored
Normal file
41
node_modules/stylelint-scss/dist/utils/hasInterpolatingAmpersand.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (selector) {
|
||||
for (var i = 0; i < selector.length; i++) {
|
||||
if (selector[i] !== "&") {
|
||||
continue;
|
||||
}
|
||||
if (!_lodash2.default.isUndefined(selector[i - 1]) && !isCombinator(selector[i - 1])) {
|
||||
return true;
|
||||
}
|
||||
if (!_lodash2.default.isUndefined(selector[i + 1]) && !isCombinator(selector[i + 1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function isCombinator(x) {
|
||||
return (/[\s+>~]/.test(x)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a selector has an interpolating ampersand
|
||||
* An "interpolating ampersand" is an "&" used to interpolate within another
|
||||
* simple selector (e.g. `&-modifier`), rather than an "&" that stands
|
||||
* on its own as a simple selector (e.g. `& .child`)
|
||||
*
|
||||
* @param {string} selector
|
||||
* @return {boolean} If `true`, the selector has an interpolating ampersand
|
||||
*/
|
205
node_modules/stylelint-scss/dist/utils/index.js
generated
vendored
Normal file
205
node_modules/stylelint-scss/dist/utils/index.js
generated
vendored
Normal file
@@ -0,0 +1,205 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _atRuleParamIndex = require("./atRuleParamIndex");
|
||||
|
||||
Object.defineProperty(exports, "atRuleParamIndex", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_atRuleParamIndex).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _beforeBlockString = require("./beforeBlockString");
|
||||
|
||||
Object.defineProperty(exports, "beforeBlockString", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_beforeBlockString).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _blockString = require("./blockString");
|
||||
|
||||
Object.defineProperty(exports, "blockString", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_blockString).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _declarationValueIndex = require("./declarationValueIndex");
|
||||
|
||||
Object.defineProperty(exports, "declarationValueIndex", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_declarationValueIndex).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _findCommentsInRaws = require("./findCommentsInRaws");
|
||||
|
||||
Object.defineProperty(exports, "findCommentsInRaws", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_findCommentsInRaws).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _hasInterpolatingAmpersand = require("./hasInterpolatingAmpersand");
|
||||
|
||||
Object.defineProperty(exports, "hasInterpolatingAmpersand", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_hasInterpolatingAmpersand).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _hasBlock = require("./hasBlock");
|
||||
|
||||
Object.defineProperty(exports, "hasBlock", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_hasBlock).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _hasEmptyLine = require("./hasEmptyLine");
|
||||
|
||||
Object.defineProperty(exports, "hasEmptyLine", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_hasEmptyLine).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isInlineComment = require("./isInlineComment");
|
||||
|
||||
Object.defineProperty(exports, "isInlineComment", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isInlineComment).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isSingleLineString = require("./isSingleLineString");
|
||||
|
||||
Object.defineProperty(exports, "isSingleLineString", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isSingleLineString).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isStandardRule = require("./isStandardRule");
|
||||
|
||||
Object.defineProperty(exports, "isStandardRule", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isStandardRule).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isStandardSelector = require("./isStandardSelector");
|
||||
|
||||
Object.defineProperty(exports, "isStandardSelector", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isStandardSelector).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isStandardSyntaxProperty = require("./isStandardSyntaxProperty");
|
||||
|
||||
Object.defineProperty(exports, "isStandardSyntaxProperty", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isStandardSyntaxProperty).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _isWhitespace = require("./isWhitespace");
|
||||
|
||||
Object.defineProperty(exports, "isWhitespace", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_isWhitespace).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _namespace = require("./namespace");
|
||||
|
||||
Object.defineProperty(exports, "namespace", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_namespace).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _optionsHaveException = require("./optionsHaveException");
|
||||
|
||||
Object.defineProperty(exports, "optionsHaveException", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_optionsHaveException).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _optionsHaveIgnored = require("./optionsHaveIgnored");
|
||||
|
||||
Object.defineProperty(exports, "optionsHaveIgnored", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_optionsHaveIgnored).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _parseNestedPropRoot = require("./parseNestedPropRoot");
|
||||
|
||||
Object.defineProperty(exports, "parseNestedPropRoot", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_parseNestedPropRoot).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _parseSelector = require("./parseSelector");
|
||||
|
||||
Object.defineProperty(exports, "parseSelector", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_parseSelector).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _sassValueParser = require("./sassValueParser");
|
||||
|
||||
Object.defineProperty(exports, "findOperators", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_sassValueParser).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _rawNodeString = require("./rawNodeString");
|
||||
|
||||
Object.defineProperty(exports, "rawNodeString", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_rawNodeString).default;
|
||||
}
|
||||
});
|
||||
|
||||
var _whitespaceChecker = require("./whitespaceChecker");
|
||||
|
||||
Object.defineProperty(exports, "whitespaceChecker", {
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return _interopRequireDefault(_whitespaceChecker).default;
|
||||
}
|
||||
});
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
22
node_modules/stylelint-scss/dist/utils/isInlineComment.js
generated
vendored
Normal file
22
node_modules/stylelint-scss/dist/utils/isInlineComment.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = isInlineComment;
|
||||
/**
|
||||
* Check if a comment is inline one (i.e. on the same line as some non-comment
|
||||
* code). Only works with comments that are not ignored by PostCSS. To work
|
||||
* with those that are ignored use `findCommentInRaws`
|
||||
*
|
||||
* @param {Comment} comment - PostCSS comment node
|
||||
* @return {boolean} true, if the comment is an inline one
|
||||
*/
|
||||
|
||||
function isInlineComment(comment) {
|
||||
var nextNode = comment.next();
|
||||
var isBeforeSomething = !!nextNode && nextNode.type !== "comment" && comment.source.end.line === nextNode.source.start.line;
|
||||
var isAfterSomething = comment.raws.before.search(/\n/) === -1;
|
||||
|
||||
return isAfterSomething || isBeforeSomething;
|
||||
}
|
9
node_modules/stylelint-scss/dist/utils/isSingleLineString.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/isSingleLineString.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (input) {
|
||||
return !/[\n\r]/.test(input);
|
||||
};
|
34
node_modules/stylelint-scss/dist/utils/isStandardRule.js
generated
vendored
Normal file
34
node_modules/stylelint-scss/dist/utils/isStandardRule.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (rule) {
|
||||
|
||||
// Get full selector
|
||||
var selector = _lodash2.default.get(rule, "raws.selector.raw", rule.selector);
|
||||
|
||||
// Custom property set (e.g. --custom-property-set: {})
|
||||
if (_lodash2.default.endsWith(selector, ":")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Called Less mixin (e.g. a { .mixin() })
|
||||
if (rule.ruleWithoutBody) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Non-outputting Less mixin definition (e.g. .mixin() {})
|
||||
if (_lodash2.default.endsWith(selector, ")") && !_lodash2.default.includes(selector, ":")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
node_modules/stylelint-scss/dist/utils/isStandardSelector.js
generated
vendored
Normal file
15
node_modules/stylelint-scss/dist/utils/isStandardSelector.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (selector) {
|
||||
|
||||
// SCSS or Less interpolation
|
||||
if (/#{.+?}|@{.+?}|\$\(.+?\)/.test(selector)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
25
node_modules/stylelint-scss/dist/utils/isStandardSyntaxProperty.js
generated
vendored
Normal file
25
node_modules/stylelint-scss/dist/utils/isStandardSyntaxProperty.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (property) {
|
||||
|
||||
// SCSS var (e.g. $var: x), list (e.g. $list: (x)) or map (e.g. $map: (key:value))
|
||||
if (property[0] === "$") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Less var (e.g. @var: x)
|
||||
if (property[0] === "@") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// SCSS or Less interpolation
|
||||
if (/#{.+?}|@{.+?}|\$\(.+?\)/.test(property)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
9
node_modules/stylelint-scss/dist/utils/isWhitespace.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/isWhitespace.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (char) {
|
||||
return [" ", "\n", "\t", "\r", "\f"].indexOf(char) !== -1;
|
||||
};
|
11
node_modules/stylelint-scss/dist/utils/namespace.js
generated
vendored
Normal file
11
node_modules/stylelint-scss/dist/utils/namespace.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = namespace;
|
||||
var prefix = "scss";
|
||||
|
||||
function namespace(ruleName) {
|
||||
return prefix + "/" + ruleName;
|
||||
}
|
9
node_modules/stylelint-scss/dist/utils/optionsHaveException.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/optionsHaveException.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (options, exceptionName) {
|
||||
return options && options.except && options.except.indexOf(exceptionName) !== -1;
|
||||
};
|
9
node_modules/stylelint-scss/dist/utils/optionsHaveIgnored.js
generated
vendored
Normal file
9
node_modules/stylelint-scss/dist/utils/optionsHaveIgnored.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (options, ignoredName) {
|
||||
return options && options.ignore && options.ignore.indexOf(ignoredName) !== -1;
|
||||
};
|
88
node_modules/stylelint-scss/dist/utils/parseNestedPropRoot.js
generated
vendored
Normal file
88
node_modules/stylelint-scss/dist/utils/parseNestedPropRoot.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = parseNestedPropRoot;
|
||||
/**
|
||||
* Attempts to parse a selector as if it"s a root for a group of nested props
|
||||
* E.g.: `margin: {`, `font: 10px/1.1 Arial {` ("{" excluded)
|
||||
*/
|
||||
|
||||
function parseNestedPropRoot(propString) {
|
||||
var modesEntered = [{
|
||||
mode: "normal",
|
||||
character: null,
|
||||
isCalculationEnabled: true
|
||||
}];
|
||||
var result = {};
|
||||
var lastModeIndex = 0;
|
||||
var propName = "";
|
||||
|
||||
for (var i = 0; i < propString.length; i++) {
|
||||
var character = propString[i];
|
||||
|
||||
// If entering/exiting a string
|
||||
if (character === "\"" || character === "'") {
|
||||
if (modesEntered[lastModeIndex].isCalculationEnabled === true) {
|
||||
modesEntered.push({
|
||||
mode: "string",
|
||||
isCalculationEnabled: false,
|
||||
character: character
|
||||
});
|
||||
lastModeIndex++;
|
||||
} else if (modesEntered[lastModeIndex].mode === "string" && modesEntered[lastModeIndex].character === character && propString[i - 1] !== "\\") {
|
||||
modesEntered.pop();
|
||||
lastModeIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
// If entering/exiting interpolation
|
||||
if (character === "{") {
|
||||
modesEntered.push({
|
||||
mode: "interpolation",
|
||||
isCalculationEnabled: true
|
||||
});
|
||||
lastModeIndex++;
|
||||
} else if (character === "}") {
|
||||
modesEntered.pop();
|
||||
lastModeIndex--;
|
||||
}
|
||||
|
||||
// Check for : outside fn call, string or interpolation. It must be at the
|
||||
// end of a string or have a whitespace between it and following value
|
||||
if (modesEntered[lastModeIndex].mode === "normal" && character === ":") {
|
||||
var propValueStr = propString.substring(i + 1);
|
||||
|
||||
if (propValueStr.length) {
|
||||
var propValue = {
|
||||
before: /^(\s*)/.exec(propValueStr)[1],
|
||||
value: propValueStr.trim()
|
||||
};
|
||||
// It's a declaration if 1) there is a whitespace after :, or
|
||||
// 2) the value is a number with/without a unit (starts with a number
|
||||
// or a dot), or
|
||||
// 3) the value is a variable (starts with $), or
|
||||
// 4) the value a string, surprisingly
|
||||
if (propValue.before === "" && !/^[0-9.$'"]/.test(propValue.value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// +1 for the colon
|
||||
propValue.sourceIndex = propValue.before.length + i + 1;
|
||||
result.propValue = propValue;
|
||||
}
|
||||
|
||||
result.propName = {
|
||||
after: /(\s*)$/.exec(propName)[1],
|
||||
value: propName.trim()
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
propName += character;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
19
node_modules/stylelint-scss/dist/utils/parseSelector.js
generated
vendored
Normal file
19
node_modules/stylelint-scss/dist/utils/parseSelector.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (selector, result, node, cb) {
|
||||
try {
|
||||
(0, _postcssSelectorParser2.default)(cb).process(selector);
|
||||
} catch (e) {
|
||||
result.warn("Cannot parse selector", { node: node });
|
||||
}
|
||||
};
|
||||
|
||||
var _postcssSelectorParser = require("postcss-selector-parser");
|
||||
|
||||
var _postcssSelectorParser2 = _interopRequireDefault(_postcssSelectorParser);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
node_modules/stylelint-scss/dist/utils/rawNodeString.js
generated
vendored
Normal file
14
node_modules/stylelint-scss/dist/utils/rawNodeString.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (node) {
|
||||
var result = "";
|
||||
if (node.raws.before) {
|
||||
result += node.raws.before;
|
||||
}
|
||||
result += node.toString();
|
||||
return result;
|
||||
};
|
860
node_modules/stylelint-scss/dist/utils/sassValueParser/index.js
generated
vendored
Normal file
860
node_modules/stylelint-scss/dist/utils/sassValueParser/index.js
generated
vendored
Normal file
@@ -0,0 +1,860 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = findOperators;
|
||||
exports.mathOperatorCharType = mathOperatorCharType;
|
||||
|
||||
/**
|
||||
* Processes a string and finds Sass operators in it
|
||||
*
|
||||
* @param {Object} args - Named arguments object
|
||||
* @param {String} args.string - the input string
|
||||
* @param {Number} args.index - the position of args.string from the start of the line
|
||||
* @param {Boolean} args.isAfterColon - pass "true" if the string is
|
||||
* a variable value, a mixin/function parameter default.
|
||||
* In such cases + and / tend to be operations more often
|
||||
* @param {Function} args.callback - will be called on every instance of
|
||||
* an operator. Accepts parameters:
|
||||
* • string - the default source string
|
||||
* • globalIndex - the string's position in the outer input
|
||||
* • startIndex - index in string, where the operator starts
|
||||
* • endIndex - index in string, where the operator ends (for `==`, etc.)
|
||||
*
|
||||
* @return {Array} array of { symbol, globalIndex, startIndex, endIndex }
|
||||
* for each operator found within a string
|
||||
*/
|
||||
function findOperators(_ref) {
|
||||
var string = _ref.string,
|
||||
globalIndex = _ref.globalIndex,
|
||||
isAfterColon = _ref.isAfterColon,
|
||||
callback = _ref.callback;
|
||||
|
||||
|
||||
var mathOperators = ["+", "/", "-", "*", "%"];
|
||||
// A stack of modes activated for the current char: string, interpolation
|
||||
// Calculations inside strings are not processed, so spaces are not linted
|
||||
var modesEntered = [{
|
||||
mode: "normal",
|
||||
isCalculationEnabled: true,
|
||||
character: null
|
||||
}];
|
||||
var result = [];
|
||||
var lastModeIndex = 0;
|
||||
|
||||
for (var i = 0; i < string.length; i++) {
|
||||
var character = string[i];
|
||||
var substringStartingWithIndex = string.substring(i);
|
||||
|
||||
// If entering/exiting a string
|
||||
if (character === "\"" || character === "'") {
|
||||
if (modesEntered[lastModeIndex].isCalculationEnabled === true) {
|
||||
modesEntered.push({
|
||||
mode: "string",
|
||||
isCalculationEnabled: false,
|
||||
character: character
|
||||
});
|
||||
lastModeIndex++;
|
||||
} else if (modesEntered[lastModeIndex].mode === "string" && modesEntered[lastModeIndex].character === character && string[i - 1] !== "\\") {
|
||||
modesEntered.pop();
|
||||
lastModeIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
// If entering/exiting interpolation (may be inside a string)
|
||||
// Comparing with length-2 because `#{` at the very end doesnt matter
|
||||
if (character === "#" && i + 1 < string.length - 2 && string[i + 1] === "{") {
|
||||
modesEntered.push({
|
||||
mode: "interpolation",
|
||||
isCalculationEnabled: true
|
||||
});
|
||||
lastModeIndex++;
|
||||
} else if (character === "}") {
|
||||
modesEntered.pop();
|
||||
lastModeIndex--;
|
||||
}
|
||||
|
||||
// Don't lint if inside a string
|
||||
if (modesEntered[lastModeIndex].isCalculationEnabled === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it's a math operator
|
||||
if (mathOperators.indexOf(character) !== -1 && mathOperatorCharType(string, i, isAfterColon) === "op" ||
|
||||
// or is "<" or ">"
|
||||
substringStartingWithIndex.search(/^[<>]([^=]|$)/) !== -1) {
|
||||
result.push({
|
||||
symbol: string[i],
|
||||
globalIndex: globalIndex,
|
||||
startIndex: i,
|
||||
endIndex: i
|
||||
});
|
||||
if (callback) {
|
||||
callback(string, globalIndex, i, i);
|
||||
}
|
||||
}
|
||||
|
||||
// "<=", ">=", "!=", "=="
|
||||
if (substringStartingWithIndex.search(/^[><=!]=/) !== -1) {
|
||||
result.push({
|
||||
symbol: string[i],
|
||||
globalIndex: globalIndex,
|
||||
startIndex: i,
|
||||
endIndex: i + 1
|
||||
});
|
||||
if (callback) {
|
||||
callback(string, globalIndex, i, i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
// result.length > 0 && console.log(string, result)
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a character is an operator, a sign (+ or -), or part of a string
|
||||
*
|
||||
* @param {String} string - the source string
|
||||
* @param {Number} index - the index of the character in string to check
|
||||
* @param {Boolean} isAfterColon - if the value string a variable
|
||||
* value, a mixin/function parameter default. In such cases + and / tend
|
||||
* to be operations more often
|
||||
* @return {String|false}
|
||||
* • "op", if the character is a operator in a math/string operation
|
||||
* • "sign" if it is a + or - before a numeric,
|
||||
* • "char" if it is a part of a string,
|
||||
* • false - if it is none from above (most likely an error)
|
||||
*/
|
||||
function mathOperatorCharType(string, index, isAfterColon) {
|
||||
// !Checking here to prevent unnecessary calculations and deep recursion
|
||||
// when calling isPrecedingOperator()
|
||||
if (["+", "/", "-", "*", "%"].indexOf(string[index]) === -1) {
|
||||
return "char";
|
||||
}
|
||||
|
||||
var character = string[index];
|
||||
// console.log(string)
|
||||
|
||||
// ---- Processing + characters
|
||||
if (character === "+") {
|
||||
// console.log('checking plus')
|
||||
return checkPlus(string, index, isAfterColon);
|
||||
}
|
||||
|
||||
// ---- Processing - characters
|
||||
if (character === "-") {
|
||||
return checkMinus(string, index);
|
||||
}
|
||||
|
||||
// ---- Processing * character
|
||||
if (character === "*") {
|
||||
return "op";
|
||||
}
|
||||
|
||||
// ---- Processing % character
|
||||
if (character === "%") {
|
||||
return checkPercent(string, index);
|
||||
}
|
||||
|
||||
// ---- Processing / character
|
||||
// http://sass-lang.com/documentation/file.SASS_REFERENCE.html#division-and-slash
|
||||
if (character === "/") {
|
||||
return checkSlash(string, index, isAfterColon);
|
||||
}
|
||||
|
||||
// console.log("nothing applies")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Functions for checking particular characterd (+, -, /)
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Checks the specified `+` char type: operator, sign (+ or -), part of string
|
||||
*
|
||||
* @param {String} string - the source string
|
||||
* @param {Number} index - the index of the character in string to check
|
||||
* @param {Boolean} isAftercolon - if the value string a variable
|
||||
* value, a mixin/function parameter default. In such cases + is always an
|
||||
* operator if surrounded by numbers/values with units
|
||||
* @return {String|false}
|
||||
* • "op", if the character is a operator in a math/string operation
|
||||
* • "sign" if it is a sign before a positive number,
|
||||
* • false - if it is none from above (most likely an error)
|
||||
*/
|
||||
function checkPlus(string, index, isAftercolon) {
|
||||
var before = string.substring(0, index);
|
||||
var after = string.substring(index + 1);
|
||||
|
||||
// If the character is at the beginning of the input
|
||||
var isAtStart_ = isAtStart(string, index);
|
||||
// If the character is at the end of the input
|
||||
var isAtEnd_ = isAtEnd(string, index);
|
||||
var isWhitespaceBefore = before.search(/\s$/) !== -1;
|
||||
var isWhitespaceAfter = after.search(/^\s/) !== -1;
|
||||
|
||||
var isValueWithUnitAfter_ = isValueWithUnitAfter(after);
|
||||
var isNumberAfter_ = isNumberAfter(after);
|
||||
var isInterpolationAfter_ = isInterpolationAfter(after);
|
||||
// The early check above helps prevent deep recursion here
|
||||
var isPrecedingOperator_ = isPrecedingOperator(string, index);
|
||||
|
||||
if (isAtStart_) {
|
||||
// console.log("+, `+<sth>` or `+ <sth>`")
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// E.g. `1+1`, `string+#fff`
|
||||
if (!isAtStart_ && !isWhitespaceBefore && !isAtEnd_ && !isWhitespaceAfter) {
|
||||
// E.g. `1-+1`
|
||||
if (isPrecedingOperator_) {
|
||||
// console.log('1+1')
|
||||
return "sign";
|
||||
}
|
||||
// console.log("+, no spaces")
|
||||
return "op";
|
||||
}
|
||||
// e.g. `something +something`
|
||||
if (!isAtEnd_ && !isWhitespaceAfter) {
|
||||
// e.g. `+something`, ` ... , +something`, etc.
|
||||
if (isNoOperandBefore(string, index)) {
|
||||
// console.log("+, nothing before")
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// e.g. `sth +10px`, `sth +1`
|
||||
if (isValueWithUnitAfter_.is && !isValueWithUnitAfter_.opsBetween || isNumberAfter_.is && !isNumberAfter_.opsBetween) {
|
||||
if (isAftercolon === true) {
|
||||
// console.log(": 10px +1")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// e.g. `(sth +10px)`, `fun(sth +1)`
|
||||
if (isInsideParens(string, index) || isInsideFunctionCall(string, index).is) {
|
||||
// console.log("+10px or +1, inside function or parens")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// e.g. `#{10px +1}`
|
||||
if (isInsideInterpolation(string, index)) {
|
||||
// console.log('+, #{10px +1}')
|
||||
return "op";
|
||||
}
|
||||
|
||||
// console.log('+, default')
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// e.g. `sth +#fff`, `sth +string`, `sth +#{...}`, `sth +$var`
|
||||
if (isStringAfter(after) || isHexColorAfter(after) || after[0] === "$" || isInterpolationAfter_.is && !isInterpolationAfter_.opsBefore) {
|
||||
// e.g. `sth+ +string`
|
||||
if (isPrecedingOperator_) {
|
||||
// console.log("+10px or +1, before is an operator")
|
||||
return "sign";
|
||||
}
|
||||
// console.log("+#000, +string, +#{sth}, +$var")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// console.log('sth +sth, default')
|
||||
return "op";
|
||||
}
|
||||
|
||||
// If the + is after a value, e.g. `$var+`
|
||||
if (!isAtStart_ && !isWhitespaceBefore) {
|
||||
// It is always an operator. Prior to Sass 4, `#{...}+` was differernt,
|
||||
// but that's not logical and had been fixed.
|
||||
// console.log('1+ sth')
|
||||
return "op";
|
||||
}
|
||||
|
||||
// If it has whitespaces on both sides
|
||||
// console.log('sth + sth')
|
||||
return "op";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified `-` character: operator, sign (+ or -), part of string
|
||||
*
|
||||
* @param {String} string - the source string
|
||||
* @param {Number} index - the index of the character in string to check
|
||||
* @return {String|false}
|
||||
* • "op", if the character is a operator in a math/string operation
|
||||
* • "sign" if it is a sign before a negative number,
|
||||
* • "char" if it is a part of a string or identifier,
|
||||
* • false - if it is none from above (most likely an error)
|
||||
*/
|
||||
function checkMinus(string, index) {
|
||||
var before = string.substring(0, index);
|
||||
var after = string.substring(index + 1);
|
||||
// If the character is at the beginning of the input
|
||||
var isAtStart_ = isAtStart(string, index);
|
||||
// If the character is at the end of the input
|
||||
var isAtEnd_ = isAtEnd(string, index);
|
||||
var isWhitespaceBefore = before.search(/\s$/) !== -1;
|
||||
var isWhitespaceAfter = after.search(/^\s/) !== -1;
|
||||
|
||||
var isValueWithUnitAfter_ = isValueWithUnitAfter(after);
|
||||
var isValueWithUnitBefore_ = isValueWithUnitBefore(before);
|
||||
var isNumberAfter_ = isNumberAfter(after);
|
||||
var isNumberBefore_ = isNumberBefore(before);
|
||||
var isInterpolationAfter_ = isInterpolationAfter(after);
|
||||
var isParensAfter_ = isParensAfter(after);
|
||||
var isParensBefore_ = isParensBefore(before);
|
||||
// The early check above helps prevent deep recursion here
|
||||
var isPrecedingOperator_ = isPrecedingOperator(string, index);
|
||||
|
||||
if (isAtStart_) {
|
||||
// console.log("-, -<sth> or - <sth>")
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// `10 - 11`
|
||||
if (!isAtEnd_ && !isAtStart_ && isWhitespaceBefore && isWhitespaceAfter) {
|
||||
// console.log("-, Op: 10px - 10px")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// e.g. `something -10px`
|
||||
if (!isAtEnd_ && !isAtStart_ && isWhitespaceBefore && !isWhitespaceAfter) {
|
||||
if (isParensAfter_.is && !isParensAfter_.opsBefore) {
|
||||
// console.log("-, Op: <sth> -(...)")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// e.g. `sth -1px`, `sth -1`.
|
||||
// Always a sign, even inside parens/function args
|
||||
if (isValueWithUnitAfter_.is && !isValueWithUnitAfter_.opsBetween || isNumberAfter_.is && !isNumberAfter_.opsBetween) {
|
||||
// console.log("-, sign: -1px or -1")
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// e.g. `sth --1`, `sth +-2px`
|
||||
if (isValueWithUnitAfter_.is && isValueWithUnitAfter_.opsBetween || isNumberAfter_.is && isNumberAfter_.opsBetween) {
|
||||
// console.log("-, op: --1px or --1")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// `<sth> -string`, `<sth> -#{...}`
|
||||
if (isStringAfter(after) || isInterpolationAfter_.is && !isInterpolationAfter_.opsBefore) {
|
||||
// console.log("-, char: -#{...}")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// e.g. `#0af -#f0a`, and edge-cases can take a hike
|
||||
if (isHexColorAfter(after) && isHexColorBefore(before.trim())) {
|
||||
// console.log("-, op: #fff-, -#fff")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// If the - is before a variable, than it's most likely an operator
|
||||
if (after[0] === "$") {
|
||||
if (isPrecedingOperator_) {
|
||||
// console.log("-, sign: -$var, another operator before")
|
||||
return "sign";
|
||||
}
|
||||
// console.log("-, op: -$var, NO other operator before")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// By default let's make it an sign for now
|
||||
// console.log('-, sign: default in <sth> -<sth>')
|
||||
return "sign";
|
||||
}
|
||||
|
||||
// No whitespace before,
|
||||
// e.g. `10x- something`
|
||||
if (!isAtEnd_ && !isAtStart_ && !isWhitespaceBefore && isWhitespaceAfter) {
|
||||
if (isParensBefore_) {
|
||||
// console.log('-, op: `(...)- <sth>`')
|
||||
return "op";
|
||||
}
|
||||
|
||||
if (isNumberBefore(before) || isHexColorBefore(before)) {
|
||||
// console.log('`-, op: 10- <sth>, #aff- <sth>`')
|
||||
return "op";
|
||||
}
|
||||
// console.log('-, char: default in <sth>- <sth>')
|
||||
return "char";
|
||||
}
|
||||
|
||||
// NO Whitespace,
|
||||
// e.g. `10px-1`
|
||||
if (!isAtEnd_ && !isAtStart_ && !isWhitespaceBefore && !isWhitespaceAfter) {
|
||||
// console.log('no spaces')
|
||||
// `<something>-1`, `<something>-10px`
|
||||
if (isValueWithUnitAfter_.is && !isValueWithUnitAfter_.opsBetween || isNumberAfter_.is && !isNumberAfter_.opsBetween) {
|
||||
// `10px-1`, `1-10px`, `1-1`, `1x-1x`
|
||||
if (isValueWithUnitBefore_ || isNumberBefore_) {
|
||||
// console.log("-, op: 1-10px")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// The - could be a "sign" here, but for now "char" does the job
|
||||
}
|
||||
// `1-$var`
|
||||
if (isNumberBefore_ && after[0] === "$") {
|
||||
// console.log("-, op: 1-$var")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// `fn()-10px`
|
||||
if (isFunctionBefore(before) && (isNumberAfter_.is && !isNumberAfter_.opsBetween || isValueWithUnitAfter_.is && !isValueWithUnitAfter_.opsBetween)) {
|
||||
// console.log("-, op: fn()-10px")
|
||||
return "op";
|
||||
}
|
||||
}
|
||||
|
||||
// And in all the other cases it's a characher inside a string
|
||||
// console.log("-, default: char")
|
||||
return "char";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified `/` character: operator, sign (+ or -), part of string
|
||||
*
|
||||
* @param {String} string - the source string
|
||||
* @param {Number} index - the index of the character in string to check
|
||||
* @param {Boolean} isAfterColon - if the value string a variable
|
||||
* value, a mixin/function parameter default. In such cases / is always an
|
||||
* operator if surrounded by numbers/values with units
|
||||
* @return {String|false}
|
||||
* • "op", if the character is a operator in a math/string operation
|
||||
* • "char" if it gets compiled as-is, e.g. `font: 10px/1.2;`,
|
||||
* • false - if it is none from above (most likely an error)
|
||||
*/
|
||||
function checkSlash(string, index, isAftercolon) {
|
||||
// Trimming these, as spaces before/after a slash don't matter
|
||||
var before = string.substring(0, index).trim();
|
||||
var after = string.substring(index + 1).trim();
|
||||
|
||||
var isValueWithUnitAfter_ = isValueWithUnitAfter(after);
|
||||
var isValueWithUnitBefore_ = isValueWithUnitBefore(before);
|
||||
var isNumberAfter_ = isNumberAfter(after);
|
||||
var isNumberBefore_ = isNumberBefore(before);
|
||||
var isParensAfter_ = isParensAfter(after);
|
||||
var isParensBefore_ = isParensBefore(before);
|
||||
|
||||
// FIRST OFF. Interpolation on any of the sides is a NO-GO for division op
|
||||
if (isInterpolationBefore(before).is || isInterpolationAfter(after).is) {
|
||||
// console.log("/, interpolation")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// e.g. `10px/normal`
|
||||
if (isStringBefore(before).is || isStringAfter(after)) {
|
||||
// console.log("/, string")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// For all other value options (numbers, value+unit, hex color)
|
||||
|
||||
// `$var/1`, `#fff/-$var`
|
||||
// Here we don't care if there is a sign before the var
|
||||
if (isVariableBefore(before) || isVariableAfter(after).is) {
|
||||
// console.log("/, variable")
|
||||
return "op";
|
||||
}
|
||||
|
||||
if (isFunctionBefore(before) || isFunctionAfter(after).is) {
|
||||
// console.log("/, function as operand")
|
||||
return "op";
|
||||
}
|
||||
|
||||
if (isParensBefore_ || isParensAfter_.is) {
|
||||
// console.log("/, function as operand")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// `$var: 10px/2; // 5px`
|
||||
if (isAftercolon === true && (isValueWithUnitAfter_.is || isNumberAfter_.is) && (isValueWithUnitBefore_ || isNumberBefore_)) {
|
||||
return "op";
|
||||
}
|
||||
|
||||
// Quick check of the following operator symbol - if it is a math operator
|
||||
if (
|
||||
// +, *, % count as operators unless after interpolation or at the start
|
||||
before.search(/[^{,(}\s]\s*[+*%]\s*[^(){},]+$/) !== -1 ||
|
||||
// We consider minus as op only if surrounded by whitespaces (` - `);
|
||||
before.search(/[^{,(}\s]\s+-\s+[^(){},]+$/) !== -1 ||
|
||||
|
||||
// `10/2 * 3`, `10/2 % 3`, with or without spaces
|
||||
after.search(/^[^(){},]+[*%]/) !== -1 ||
|
||||
// `10px/2px+1`, `10px/2px+ 1`
|
||||
after.search(/^[^(){},\s]+[+]/) !== -1 ||
|
||||
// Anything but `10px/2px +1`, `10px/2px +1px`
|
||||
after.search(/^[^(){},\s]+\s+(\+\D)/) !== -1 ||
|
||||
// Following ` -`: only if `$var` after (`10/10 -$var`)
|
||||
after.search(/^[^(){},\s]+\s+-(\$|\s)/) !== -1 ||
|
||||
// Following `-`: only if number after (`10s/10s-10`, `10s/10s-.1`)
|
||||
after.search(/^[^(){},\s]+-(\.){0,1}\d/) !== -1 ||
|
||||
// Or if there is a number before anything but string after (not `10s/1-str`,)
|
||||
after.search(/^(\d*\.){0,1}\d+-\s*[^#a-zA-Z_\s]/) !== -1) {
|
||||
// console.log("/, math op around")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// e.g. `(1px/1)`, `fn(7 / 15)`, but not `url(8/11)`
|
||||
var isInsideFn = isInsideFunctionCall(string, index);
|
||||
if (isInsideParens(string, index) || isInsideFn.is && isInsideFn.fn !== "url") {
|
||||
// console.log("/, parens or function arg")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// console.log("/, default")
|
||||
return "char";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the specified `%` character: operator or part of value
|
||||
*
|
||||
* @param {String} string - the source string
|
||||
* @param {Number} index - the index of the character in string to check
|
||||
* @return {String|false}
|
||||
* • "op", if the character is a operator in a math/string operation
|
||||
* • "char" if it gets compiled as-is, e.g. `width: 10%`,
|
||||
* • false - if it is none from above (most likely an error)
|
||||
*/
|
||||
function checkPercent(string, index) {
|
||||
// Trimming these, as spaces before/after a slash don't matter
|
||||
var before = string.substring(0, index);
|
||||
var after = string.substring(index + 1);
|
||||
|
||||
// If the character is at the beginning of the input
|
||||
var isAtStart_ = isAtStart(string, index);
|
||||
// If the character is at the end of the input
|
||||
var isAtEnd_ = isAtEnd(string, index);
|
||||
var isWhitespaceBefore = before.search(/\s$/) !== -1;
|
||||
var isWhitespaceAfter = after.search(/^\s/) !== -1;
|
||||
|
||||
var isParensBefore_ = isParensBefore(before);
|
||||
|
||||
// FIRST OFF. Interpolation on any of the sides is a NO-GO
|
||||
if (isInterpolationBefore(before.trim()).is || isInterpolationAfter(after.trim()).is) {
|
||||
// console.log("%, interpolation")
|
||||
return "char";
|
||||
}
|
||||
|
||||
if (isAtStart_ || isAtEnd_) {
|
||||
// console.log("%, start/end")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// In `<sth> %<sth>` it's most likely an operator (except for inteprolation
|
||||
// checked above)
|
||||
if (isWhitespaceBefore && !isWhitespaceAfter) {
|
||||
// console.log("%, `<sth> %<sth>`")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// `$var% 1`, `$var%1`, `$var%-1`
|
||||
if (isVariableBefore(before) || isParensBefore_) {
|
||||
// console.log("%, after a variable, function or parens")
|
||||
return "op";
|
||||
}
|
||||
|
||||
// in all other cases in `<sth>% <sth>` it is most likely a unit
|
||||
if (!isWhitespaceBefore && isWhitespaceAfter) {
|
||||
// console.log("%, `<sth>% <sth>`")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// console.log("%, default")
|
||||
return "char";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Lots of elementary helpers
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
function isAtStart(string, index) {
|
||||
var before = string.substring(0, index).trim();
|
||||
return before.length === 0 || before.search(/[({,]$/) !== -1;
|
||||
}
|
||||
|
||||
function isAtEnd(string, index) {
|
||||
var after = string.substring(index + 1).trim();
|
||||
return after.length === 0 || after.search(/^[,)}]/) !== -1;
|
||||
}
|
||||
|
||||
function isInsideParens(string, index) {
|
||||
var before = string.substring(0, index).trim();
|
||||
var after = string.substring(index + 1).trim();
|
||||
|
||||
if (before.search(/(?:^|[,{]|\s)\(\s*[^(){},]+$/) !== -1 && after.search(/^[^(){},\s]+\s*\)/) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isInsideInterpolation(string, index) {
|
||||
var before = string.substring(0, index).trim();
|
||||
|
||||
if (before.search(/#\{[^}]*$/) !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the character is inside a function agruments
|
||||
*
|
||||
* @param {String} string - the input string
|
||||
* @param {Number} index - current character index
|
||||
* @return {Object} return
|
||||
* {Boolean} return.is - if inside a function arguments
|
||||
* {String} return.fn - function name
|
||||
*/
|
||||
function isInsideFunctionCall(string, index) {
|
||||
var result = { is: false, fn: null };
|
||||
var before = string.substring(0, index).trim();
|
||||
var after = string.substring(index + 1).trim();
|
||||
var beforeMatch = before.match(/([a-zA-Z_-][a-zA-Z0-9_-]*)\([^(){},]+$/);
|
||||
|
||||
if (beforeMatch && beforeMatch[0] && after.search(/^[^({},]+\)/) !== -1) {
|
||||
result.is = true;
|
||||
result.fn = beforeMatch[1];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is a string before the character.
|
||||
* Also checks if there is a math operator in between
|
||||
*
|
||||
* @param {String} before - the input string that preceses the character
|
||||
* @return {Object} return
|
||||
* {Boolean} return.is - if there is a string
|
||||
* {String} return.opsBetween - if there are operators in between
|
||||
*/
|
||||
function isStringBefore(before) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
var stringOpsClipped = before.replace(/(\s*[+/*%]|\s+-)+$/, "");
|
||||
|
||||
if (stringOpsClipped !== before) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
// If it is quoted
|
||||
if (stringOpsClipped[stringOpsClipped.length - 1] == "\"" || stringOpsClipped[stringOpsClipped.length - 1] == "'") {
|
||||
result.is = true;
|
||||
} else if (stringOpsClipped.search(/(?:^|[/(){},: ])([a-zA-Z_][a-zA-Z_0-9-]*|-+[a-zA-Z_]+[a-zA-Z_0-9-]*)$/) !== -1) {
|
||||
// First pattern: a1, a1a, a-1,
|
||||
result.is = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function isStringAfter(after) {
|
||||
var stringTrimmed = after.trim();
|
||||
|
||||
// If it is quoted
|
||||
if (stringTrimmed[0] == "\"" || stringTrimmed[0] == "'") return true;
|
||||
|
||||
// e.g. `a1`, `a1a`, `a-1`, and even `--s323`
|
||||
if (stringTrimmed.search(/^([a-zA-Z_][a-zA-Z_0-9-]*|-+[a-zA-Z_]+[a-zA-Z_0-9-]*)(?:$|[)}, ])/) !== -1) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isInterpolationAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
var matches = after.match(/^\s*([+/*%-]\s*)*#{/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isParensAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
var matches = after.match(/^\s*([+/*%-]\s*)*\(/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isParensBefore(before) {
|
||||
return before.search(/\)\s*$/) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is an interpolation before the character.
|
||||
* Also checks if there is a math operator in between
|
||||
*
|
||||
* @param {String} before - the input string that preceses the character
|
||||
* @return {Object} return
|
||||
* {Boolean} return.is - if there is an interpolation
|
||||
* {String} return.opsBetween - if there are operators in between
|
||||
*/
|
||||
function isInterpolationBefore(before) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
// Removing preceding operators if any
|
||||
var beforeOpsClipped = before.replace(/(\s*[+/*%-])+$/, "");
|
||||
if (beforeOpsClipped !== before) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
if (beforeOpsClipped[beforeOpsClipped.length - 1] === "}") {
|
||||
result.is = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isValueWithUnitBefore(before) {
|
||||
// 1px, 0.1p-x, .2p-, 11.2pdf-df1df_
|
||||
// Surprisingly, ` d.10px` - .10px is separated from a sequence
|
||||
// and is considered a value with a unit
|
||||
if (before.trim().search(/(^|[/(, ]|\.)\d[a-zA-Z_0-9-]+$/) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValueWithUnitAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
// 1px, 0.1p-x, .2p-, 11.2pdf-dfd1f_
|
||||
// Again, ` d.10px` - .10px is separated from a sequence
|
||||
// and is considered a value with a unit
|
||||
var matches = after.match(/^\s*([+/*%-]\s*)*(\d+(\.\d+){0,1}|\.\d+)[a-zA-Z_0-9-]+(?:$|[)}, ])/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isNumberAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
var matches = after.match(/^\s*([+/*%-]\s*)*(\d+(\.\d+){0,1}|\.\d+)(?:$|[)}, ])/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isNumberBefore(before) {
|
||||
if (before.trim().search(/(?:^|[/(){},\s])(\d+(\.\d+){0,1}|\.\d+)$/) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function isVariableBefore(before) {
|
||||
return before.trim().search(/\$[a-zA-Z_0-9-]+$/) !== -1;
|
||||
}
|
||||
|
||||
function isVariableAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
var matches = after.match(/^\s*([+/*%-]\s*)*\$/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function isFunctionBefore(before) {
|
||||
return before.trim().search(/[a-zA-Z0-9_-]\(.*?\)\s*$/) !== -1;
|
||||
}
|
||||
|
||||
function isFunctionAfter(after) {
|
||||
var result = { is: false, opsBetween: false };
|
||||
// `-fn()` is a valid function name, so if a - should be a sign/operator,
|
||||
// it must have a space after
|
||||
var matches = after.match(/^\s*(-\s+|[+/*%]\s*)*[a-zA_Z_-][a-zA-Z_0-9-]*\(/);
|
||||
if (matches) {
|
||||
if (matches[0]) {
|
||||
result.is = true;
|
||||
}
|
||||
if (matches[1]) {
|
||||
result.opsBetween = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the input string is a hex color value
|
||||
*
|
||||
* @param {String} string - the input
|
||||
* @return {Boolean} true, if the input is a hex color
|
||||
*/
|
||||
function isHexColor(string) {
|
||||
return string.trim().search(/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/) !== -1;
|
||||
}
|
||||
|
||||
function isHexColorAfter(after) {
|
||||
var afterTrimmed = after.match(/(.*?)(?:[)},+/*%-]|\s|$)/)[1].trim();
|
||||
return isHexColor(afterTrimmed);
|
||||
}
|
||||
|
||||
function isHexColorBefore(before) {
|
||||
if (before.search(/(?:[/(){},+/*%-\s]|^)#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/) !== -1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is no operand before the currenc char
|
||||
* In other words, the current char is at the start of a possible operation,
|
||||
* e.g. at the string start, after the opening paren or after a comma
|
||||
*
|
||||
* @param {String} string - the input string
|
||||
* @param {Number} index - current char's position in string
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function isNoOperandBefore(string, index) {
|
||||
var before = string.substring(0, index).trim();
|
||||
return before.length === 0 || before.search(/[({,]&/) !== -1;
|
||||
}
|
||||
|
||||
function isPrecedingOperator(string, index) {
|
||||
var prevCharIndex = -1;
|
||||
for (var i = index - 1; i >= 0; i--) {
|
||||
if (string[i].search(/\s/) === -1) {
|
||||
prevCharIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevCharIndex === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mathOperatorCharType(string, prevCharIndex) === "op") {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
339
node_modules/stylelint-scss/dist/utils/whitespaceChecker.js
generated
vendored
Normal file
339
node_modules/stylelint-scss/dist/utils/whitespaceChecker.js
generated
vendored
Normal file
@@ -0,0 +1,339 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
exports.default = function (targetWhitespace, expectation, messages) {
|
||||
|
||||
// Keep track of active arguments in order to avoid passing
|
||||
// too much stuff around, making signatures long and confusing.
|
||||
// This variable gets reset anytime a checking function is called.
|
||||
var activeArgs = void 0;
|
||||
|
||||
/**
|
||||
* Check for whitespace *before* a character.
|
||||
*
|
||||
* @param {object} args - Named arguments object
|
||||
* @param {string} args.source - The source string
|
||||
* @param {number} args.index - The index of the character to check before
|
||||
* @param {function} args.err - If a violation is found, this callback
|
||||
* will be invoked with the relevant warning message.
|
||||
* Typically this callback will report() the violation.
|
||||
* @param {function} args.errTarget - If a violation is found, this string
|
||||
* will be sent to the relevant warning message.
|
||||
* @param {string} [args.lineCheckStr] - Single- and multi-line checkers
|
||||
* will use this string to determine whether they should proceed,
|
||||
* i.e. if this string is one line only, single-line checkers will check,
|
||||
* multi-line checkers will ignore.
|
||||
* If none is passed, they will use `source`.
|
||||
* @param {boolean} [args.onlyOneChar=false] - Only check *one* character before.
|
||||
* By default, "always-*" checks will look for the `targetWhitespace` one
|
||||
* before and then ensure there is no whitespace two before. This option
|
||||
* bypasses that second check.
|
||||
* @param {boolean} [args.allowIndentation=false] - Allow arbitrary indentation
|
||||
* between the `targetWhitespace` (almost definitely a newline) and the `index`.
|
||||
* With this option, the checker will see if a newline *begins* the whitespace before
|
||||
* the `index`.
|
||||
*/
|
||||
function before(_ref) {
|
||||
var source = _ref.source,
|
||||
index = _ref.index,
|
||||
err = _ref.err,
|
||||
errTarget = _ref.errTarget,
|
||||
lineCheckStr = _ref.lineCheckStr,
|
||||
_ref$onlyOneChar = _ref.onlyOneChar,
|
||||
onlyOneChar = _ref$onlyOneChar === undefined ? false : _ref$onlyOneChar,
|
||||
_ref$allowIndentation = _ref.allowIndentation,
|
||||
allowIndentation = _ref$allowIndentation === undefined ? false : _ref$allowIndentation;
|
||||
|
||||
activeArgs = { source: source, index: index, err: err, errTarget: errTarget, onlyOneChar: onlyOneChar, allowIndentation: allowIndentation };
|
||||
switch (expectation) {
|
||||
case "always":
|
||||
expectBefore();
|
||||
break;
|
||||
case "never":
|
||||
rejectBefore();
|
||||
break;
|
||||
case "always-single-line":
|
||||
if (!(0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
expectBefore(messages.expectedBeforeSingleLine);
|
||||
break;
|
||||
case "never-single-line":
|
||||
if (!(0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
rejectBefore(messages.rejectedBeforeSingleLine);
|
||||
break;
|
||||
case "always-multi-line":
|
||||
if ((0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
expectBefore(messages.expectedBeforeMultiLine);
|
||||
break;
|
||||
case "never-multi-line":
|
||||
if ((0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
rejectBefore(messages.rejectedBeforeMultiLine);
|
||||
break;
|
||||
default:
|
||||
throw (0, _configurationError2.default)("Unknown expectation \"" + expectation + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for whitespace *after* a character.
|
||||
*
|
||||
* Parameters are pretty much the same as for `before()`, above, just substitute
|
||||
* the word "after" for "before".
|
||||
*/
|
||||
function after(_ref2) {
|
||||
var source = _ref2.source,
|
||||
index = _ref2.index,
|
||||
err = _ref2.err,
|
||||
errTarget = _ref2.errTarget,
|
||||
lineCheckStr = _ref2.lineCheckStr,
|
||||
_ref2$onlyOneChar = _ref2.onlyOneChar,
|
||||
onlyOneChar = _ref2$onlyOneChar === undefined ? false : _ref2$onlyOneChar;
|
||||
|
||||
activeArgs = { source: source, index: index, err: err, errTarget: errTarget, onlyOneChar: onlyOneChar };
|
||||
switch (expectation) {
|
||||
case "always":
|
||||
expectAfter();
|
||||
break;
|
||||
case "never":
|
||||
rejectAfter();
|
||||
break;
|
||||
case "always-single-line":
|
||||
if (!(0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
expectAfter(messages.expectedAfterSingleLine);
|
||||
break;
|
||||
case "never-single-line":
|
||||
if (!(0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
rejectAfter(messages.rejectedAfterSingleLine);
|
||||
break;
|
||||
case "always-multi-line":
|
||||
if ((0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
expectAfter(messages.expectedAfterMultiLine);
|
||||
break;
|
||||
case "never-multi-line":
|
||||
if ((0, _isSingleLineString2.default)(lineCheckStr || source)) {
|
||||
return;
|
||||
}
|
||||
rejectAfter(messages.rejectedAfterMultiLine);
|
||||
break;
|
||||
default:
|
||||
throw (0, _configurationError2.default)("Unknown expectation \"" + expectation + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
function beforeAllowingIndentation(obj) {
|
||||
before((0, _lodash.assign)({}, obj, { allowIndentation: true }));
|
||||
}
|
||||
|
||||
function expectBefore() {
|
||||
var messageFunc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messages.expectedBefore;
|
||||
|
||||
if (activeArgs.allowIndentation) {
|
||||
expectBeforeAllowingIndentation(messageFunc);
|
||||
return;
|
||||
}
|
||||
|
||||
var _activeArgs = activeArgs,
|
||||
source = _activeArgs.source,
|
||||
index = _activeArgs.index;
|
||||
|
||||
var oneCharBefore = source[index - 1];
|
||||
var twoCharsBefore = source[index - 2];
|
||||
|
||||
if (!isValue(oneCharBefore)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetWhitespace === "newline") {
|
||||
// If index is preceeded by a Windows CR-LF ...
|
||||
if (oneCharBefore === "\n" && twoCharsBefore === "\r") {
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(source[index - 3])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If index is followed by a Unix LF ...
|
||||
if (oneCharBefore === "\n" && twoCharsBefore !== "\r") {
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(twoCharsBefore)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetWhitespace === "space" && oneCharBefore === " ") {
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(twoCharsBefore)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeArgs.err(messageFunc(activeArgs.errTarget ? activeArgs.errTarget : source[index]));
|
||||
}
|
||||
|
||||
function expectBeforeAllowingIndentation() {
|
||||
var messageFunc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messages.expectedBefore;
|
||||
var _activeArgs2 = activeArgs,
|
||||
source = _activeArgs2.source,
|
||||
index = _activeArgs2.index,
|
||||
err = _activeArgs2.err;
|
||||
|
||||
var expectedChar = function () {
|
||||
if (targetWhitespace === "newline") {
|
||||
return "\n";
|
||||
}
|
||||
if (targetWhitespace === "space") {
|
||||
return " ";
|
||||
}
|
||||
}();
|
||||
var i = index - 1;
|
||||
while (source[i] !== expectedChar) {
|
||||
if (source[i] === "\t" || source[i] === " ") {
|
||||
i--;
|
||||
continue;
|
||||
}
|
||||
err(messageFunc(activeArgs.errTarget ? activeArgs.errTarget : source[index]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function rejectBefore() {
|
||||
var messageFunc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messages.rejectedBefore;
|
||||
var _activeArgs3 = activeArgs,
|
||||
source = _activeArgs3.source,
|
||||
index = _activeArgs3.index;
|
||||
|
||||
var oneCharBefore = source[index - 1];
|
||||
|
||||
if (isValue(oneCharBefore) && (0, _isWhitespace2.default)(oneCharBefore)) {
|
||||
activeArgs.err(messageFunc(activeArgs.errTarget ? activeArgs.errTarget : source[index]));
|
||||
}
|
||||
}
|
||||
|
||||
function afterOneOnly(obj) {
|
||||
after((0, _lodash.assign)({}, obj, { onlyOneChar: true }));
|
||||
}
|
||||
|
||||
function expectAfter() {
|
||||
var messageFunc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messages.expectedAfter;
|
||||
var _activeArgs4 = activeArgs,
|
||||
source = _activeArgs4.source,
|
||||
index = _activeArgs4.index;
|
||||
|
||||
|
||||
var oneCharAfter = index + 1 < source.length ? source[index + 1] : "";
|
||||
var twoCharsAfter = index + 2 < source.length ? source[index + 2] : "";
|
||||
|
||||
if (!isValue(oneCharAfter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetWhitespace === "newline") {
|
||||
// If index is followed by a Windows CR-LF ...
|
||||
if (oneCharAfter === "\r" && twoCharsAfter === "\n") {
|
||||
var threeCharsAfter = index + 3 < source.length ? source[index + 3] : "";
|
||||
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(threeCharsAfter)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If index is followed by a Unix LF ...
|
||||
if (oneCharAfter === "\n") {
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(twoCharsAfter)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (targetWhitespace === "space" && oneCharAfter === " ") {
|
||||
if (activeArgs.onlyOneChar || !(0, _isWhitespace2.default)(twoCharsAfter)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeArgs.err(messageFunc(activeArgs.errTarget ? activeArgs.errTarget : source[index]));
|
||||
}
|
||||
|
||||
function rejectAfter() {
|
||||
var messageFunc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : messages.rejectedAfter;
|
||||
var _activeArgs5 = activeArgs,
|
||||
source = _activeArgs5.source,
|
||||
index = _activeArgs5.index;
|
||||
|
||||
var oneCharAfter = index + 1 < source.length ? source[index + 1] : "";
|
||||
|
||||
if (isValue(oneCharAfter) && (0, _isWhitespace2.default)(oneCharAfter)) {
|
||||
activeArgs.err(messageFunc(activeArgs.errTarget ? activeArgs.errTarget : source[index]));
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
before: before,
|
||||
beforeAllowingIndentation: beforeAllowingIndentation,
|
||||
after: after,
|
||||
afterOneOnly: afterOneOnly
|
||||
};
|
||||
};
|
||||
|
||||
var _lodash = require("lodash");
|
||||
|
||||
var _isWhitespace = require("./isWhitespace");
|
||||
|
||||
var _isWhitespace2 = _interopRequireDefault(_isWhitespace);
|
||||
|
||||
var _isSingleLineString = require("./isSingleLineString");
|
||||
|
||||
var _isSingleLineString2 = _interopRequireDefault(_isSingleLineString);
|
||||
|
||||
var _configurationError = require("./configurationError");
|
||||
|
||||
var _configurationError2 = _interopRequireDefault(_configurationError);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function isValue(x) {
|
||||
return x !== undefined && x !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a whitespaceChecker, which exposes the following functions:
|
||||
* - `before()`
|
||||
* - `beforeAllowingIndentation()`
|
||||
* - `after()`
|
||||
* - `afterOneOnly()`
|
||||
*
|
||||
* @param {"space"|"newline"} targetWhitespace - This is a keyword instead
|
||||
* of the actual character (e.g. " ") in order to accommodate
|
||||
* different styles of newline ("\n" vs "\r\n")
|
||||
* @param {
|
||||
* "always"|"never"
|
||||
* |"always-single-line"|"always-multi-line"
|
||||
* | "never-single-line"|"never-multi-line"
|
||||
* } expectation
|
||||
* @param {object} messages - An object of message functions;
|
||||
* calling `before*()` or `after*()` and the `expectation` that is passed
|
||||
* determines which message functions are required
|
||||
* @param {function} [messages.exectedBefore]
|
||||
* @param {function} [messages.rejectedBefore]
|
||||
* @param {function} [messages.expectedAfter]
|
||||
* @param {function} [messages.rejectedAfter]
|
||||
* @param {function} [messages.expectedBeforeSingleLine]
|
||||
* @param {function} [messages.rejectedBeforeSingleLine]
|
||||
* @param {function} [messages.expectedBeforeMultiLine]
|
||||
* @param {function} [messages.rejectedBeforeMultiLine]
|
||||
* @return {object} The checker, with its exposed checking functions
|
||||
*/
|
Reference in New Issue
Block a user