UNPKG

2.11 kBMarkdownView Raw
1# stylelint-processor-arbitrary-tags
2
3[![Build Status](https://travis-ci.com/mapbox/stylelint-processor-arbitrary-tags.svg?branch=main)](https://travis-ci.com/mapbox/stylelint-processor-arbitrary-tags)
4
5A [stylelint processor](http://stylelint.io/user-guide/configuration/#processors) that allows you to lint CSS within arbitrary tags.
6
7The module uses a regular expression to identify code within the specified tags, then passes the code on to stylelint.
8
9By default, it looks for code within `<style>` tags (see default options below). But you can change the regular expression to find code within other tags, like `{% highlight css %}...{% endhighlight %}` for Jekyll templates, or `/* start css */.../* end css */` within a JS file, or who knows what else.
10
11## Install
12
13```
14npm install @mapbox/stylelint-processor-arbitrary-tags
15```
16
17## Options
18
19### startTag
20
21Type: `string` that's RegExp-ready
22
23Default:
24```
25'[^`\'"]<style[\\s\\S]*?>'
26```
27
28### endTag
29
30Type: `string` that's RegExp-ready
31
32Default:
33```
34'</\\s*?style>'
35```
36
37### body
38
39Type: `string` that's RegExp-ready
40
41Default:
42```
43'[\\s\\S]*?'
44```
45
46### fileFilterRegex
47
48Type: `array<RegExp|string>` that's an array of regular expressions or strings that describe files that you want to be processed with this module.
49Matches will be processed; files that do not match will not be.
50
51Given the following value, only `.html` files will be processed:
52
53```js
54fileFilterRegex: [/\.html$/]
55```
56
57You can also use regular expression strings instead of regular expression literals. This is necessary if you are using yaml-based configuration and can't use regular expression literals. Yaml variant of example above:
58
59```yaml
60 - fileFilterRegex:
61 - '\.html$'
62```
63
64This is useful when you want to create different settings for HTML and markdown, for instance.
65
66When empty (`[]`), every file will pass through the filter and be processed by this module.
67
68Default:
69
70```js
71[]
72```
73
74## Caveats
75
76**Do not use this processor with the `no-empty-source` rule**. If you do, you will have warnings whenever a file does not contain any matches for your regular expression.