diff --git a/.eslintignore b/.eslintignore index 4b248cbe..42b0963a 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,3 +9,4 @@ docs/ plopfile.js jest.config.js commitlint.config.js +stylelint-local-rules.js diff --git a/.prettierignore b/.prettierignore index 627863f3..3959bde2 100644 --- a/.prettierignore +++ b/.prettierignore @@ -13,3 +13,5 @@ coverage dist data docs + +stylelint-local-rules.js diff --git a/.stylelintrc.json b/.stylelintrc.json index 433d0ae1..00bd1120 100644 --- a/.stylelintrc.json +++ b/.stylelintrc.json @@ -1,8 +1,18 @@ { "extends": ["stylelint-config-standard", "stylelint-config-prettier", "stylelint-config-recommended"], - "plugins": ["stylelint-order", "stylelint-scss", "stylelint-prettier", "stylelint-selector-bem-pattern"], + "plugins": [ + "stylelint-order", + "stylelint-scss", + "stylelint-prettier", + "stylelint-selector-bem-pattern", + "./stylelint-local-rules.js" + ], "rules": { "indentation": 4, + "selector-max-id": null, + "selector-no-vendor-prefix": null, + "shorthand-property-no-redundant-values": true, + "okta/no-absolute-urls": true, "no-invalid-position-at-import-rule": null, "scss/at-rule-no-unknown": true, "prettier/prettier": true, @@ -23,11 +33,20 @@ "max-empty-lines": null, "no-duplicate-selectors": null, "selector-pseudo-element-colon-notation": null, - "selector-class-pattern": null, + "declaration-bang-space-after": "never", + "declaration-bang-space-before": "always", + "declaration-block-no-duplicate-properties": [ + true, + { + "ignore": ["consecutive-duplicates-with-different-values"] + } + ], + "selector-class-pattern": "[-a-z0-9]", + "selector-id-pattern": "[-a-z0-9]", "selector-no-qualifying-type": [ true, { - "ignore": ["attribute", "class"] + "ignore": ["attribute", "class", "id"] } ], "plugin/selector-bem-pattern": { @@ -53,6 +72,35 @@ "for" ] } + ], + "unit-allowed-list": [ + "ch", + "em", + "ex", + "rem", + "cm", + "in", + "mm", + "pc", + "pt", + "px", + "q", + "vh", + "vw", + "vmin", + "vmax", + "deg", + "grad", + "rad", + "turn", + "ms", + "s", + "Hz", + "kHz", + "dpi", + "dpcm", + "dppx", + "%" ] } } diff --git a/CHANGELOG.md b/CHANGELOG.md index 753dac0b..99b689ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.0.2 (2021-07-23) +## 0.0.2 (2021-08-12) ### Features diff --git a/api/caillen/images/css/styles.css b/api/caillen/images/css/styles.css index 0ea0a84e..4a046081 100644 --- a/api/caillen/images/css/styles.css +++ b/api/caillen/images/css/styles.css @@ -22,7 +22,7 @@ body a { .title { position: absolute; width: 100%; - margin: 10px 0 0 0; + margin: 10px 0 0; text-align: center; } @@ -36,7 +36,7 @@ body a { width: 100%; text-align: center; bottom: 0; - margin: 0 0 10px 0; + margin: 0 0 10px; } .div-icons { diff --git a/stylelint-local-rules.js b/stylelint-local-rules.js new file mode 100644 index 00000000..6faee22d --- /dev/null +++ b/stylelint-local-rules.js @@ -0,0 +1,32 @@ +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