forked from okta/okta-signin-widget
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstylelint-local-rules.js
More file actions
29 lines (26 loc) · 896 Bytes
/
Copy pathstylelint-local-rules.js
File metadata and controls
29 lines (26 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const stylelint = require('stylelint');
const { report, ruleMessages, validateOptions } = stylelint.utils;
const ruleName = 'okta/no-absolute-urls';
const messages = ruleMessages(ruleName, {
expected: 'URLs starting with \'/\' are not allowed in SCSS files. Fix this by replacing with a relative link.',
});
module.exports = stylelint.createPlugin(ruleName, function getPlugin() {
return function lint(root, result) {
const validOptions = validateOptions(result, ruleName, {});
if (!validOptions) { return; }
root.walkDecls(decl => {
const field = decl.toString().toLowerCase();
const match = field.match(/url\(['"]\//g);
if (match) {
report({
ruleName,
result,
message: messages.expected,
node: decl,
});
}
});
};
});
module.exports.ruleName = ruleName;
module.exports.messages = messages;