"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" });