(isEnabled, options)
| 13 | * Can be used in theme files to ensure that everything is inside a mixin. |
| 14 | */ |
| 15 | const ruleFn: Rule<boolean, string> = (isEnabled, options) => { |
| 16 | return (root, result) => { |
| 17 | if (!isEnabled) { |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | const filePattern = options.filePattern ? new RegExp(options.filePattern) : null; |
| 22 | const fileName = basename(root.source!.input.file!); |
| 23 | |
| 24 | if ((filePattern !== null && !filePattern.test(fileName)) || !root.nodes) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | // Go through all the nodes and report a warning for every CSS rule or mixin inclusion. |
| 29 | // We use a regular `forEach`, instead of the PostCSS walker utils, because we only care |
| 30 | // about the top-level nodes. |
| 31 | root.nodes.forEach(node => { |
| 32 | if (node.type === 'rule' || (node.type === 'atrule' && node.name === 'include')) { |
| 33 | utils.report({ |
| 34 | result, |
| 35 | ruleName, |
| 36 | node, |
| 37 | message: |
| 38 | filePattern !== null |
| 39 | ? messages.expectedWithPattern(filePattern) |
| 40 | : messages.expectedAllFiles(), |
| 41 | }); |
| 42 | } |
| 43 | }); |
| 44 | }; |
| 45 | }; |
| 46 | |
| 47 | ruleFn.ruleName = ruleName; |
| 48 | ruleFn.messages = messages; |
nothing calls this directly
no outgoing calls
no test coverage detected