Skip to content

Commit 386186e

Browse files
feat: add ignoredKeys in settings (francoismassart#232)
* feat: add `ignoredKeys` in settings * chore: cleaning debug console call * 3.11.0-beta.0 * chore: add `tv` in default `callees`
1 parent 052aacb commit 386186e

19 files changed

+207
-34
lines changed

docs/rules/classnames-order.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ Examples of **correct** code for this rule:
3232
...
3333
```
3434

35-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
35+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
3636

3737
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
3838

3939
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
4040

41+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
42+
43+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
44+
You can specify which key(s) won't be parsed by the plugin using this setting.
45+
For example, `cva` has `compoundVariants` and `defaultVariants`.
46+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
47+
4148
### `config` (default: `"tailwind.config.js"`)
4249

4350
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/enforces-negative-arbitrary-values.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,19 @@ Examples of **correct** code for this rule:
5050
...
5151
```
5252

53-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
53+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
5454

5555
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
5656

5757
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
5858

59+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
60+
61+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
62+
You can specify which key(s) won't be parsed by the plugin using this setting.
63+
For example, `cva` has `compoundVariants` and `defaultVariants`.
64+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
65+
5966
### `config` (default: `"tailwind.config.js"`)
6067

6168
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/enforces-shorthand.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,19 @@ If indeed, you are using the `classnames-order` rule, then it'll be automaticall
4242
...
4343
```
4444

45-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
45+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
4646

4747
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
4848

4949
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
5050

51+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
52+
53+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
54+
You can specify which key(s) won't be parsed by the plugin using this setting.
55+
For example, `cva` has `compoundVariants` and `defaultVariants`.
56+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
57+
5158
### `config` (default: `"tailwind.config.js"`)
5259

5360
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/migration-from-tailwind-2.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,19 @@ This rule will report the issue but **it will not fix it for you**...
8787
...
8888
```
8989

90-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
90+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
9191

9292
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
9393

9494
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
9595

96+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
97+
98+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
99+
You can specify which key(s) won't be parsed by the plugin using this setting.
100+
For example, `cva` has `compoundVariants` and `defaultVariants`.
101+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
102+
96103
### `config` (default: `"tailwind.config.js"`)
97104

98105
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/no-arbitrary-value.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ Examples of **correct** code for this rule:
3232
...
3333
```
3434

35-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
35+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
3636

3737
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
3838

3939
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
4040

41+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
42+
43+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
44+
You can specify which key(s) won't be parsed by the plugin using this setting.
45+
For example, `cva` has `compoundVariants` and `defaultVariants`.
46+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
47+
4148
### `config` (default: `"tailwind.config.js"`)
4249

4350
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/no-contradicting-classname.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ Examples of **correct** code for this rule:
3232
...
3333
```
3434

35-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
35+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
3636

3737
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
3838

3939
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
4040

41+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
42+
43+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
44+
You can specify which key(s) won't be parsed by the plugin using this setting.
45+
For example, `cva` has `compoundVariants` and `defaultVariants`.
46+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
47+
4148
### `config` (default: `"tailwind.config.js"`)
4249

4350
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

docs/rules/no-custom-classname.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,19 @@ Examples of **correct** code for this rule:
3434
...
3535
```
3636

37-
### `callees` (default: `["classnames", "clsx", "ctl"]`)
37+
### `callees` (default: `["classnames", "clsx", "ctl", "cva", "tv"]`)
3838

3939
If you use some utility library like [@netlify/classnames-template-literals](https://github.com/netlify/classnames-template-literals), you can add its name to the list to make sure it gets parsed by this rule.
4040

4141
For best results, gather the declarative classnames together, avoid mixing conditional classnames in between, move them at the end.
4242

43+
### `ignoredKeys` (default: `["compoundVariants", "defaultVariants"]`)
44+
45+
Using libraries like `cva`, some of its object keys are not meant to contain classnames in its value(s).
46+
You can specify which key(s) won't be parsed by the plugin using this setting.
47+
For example, `cva` has `compoundVariants` and `defaultVariants`.
48+
NB: As `compoundVariants` can have classnames inside its `class` property, you can also use a callee to make sure this inner part gets parsed while its parent is ignored.
49+
4350
### `config` (default: `"tailwind.config.js"`)
4451

4552
By default the plugin will try to load the file `tailwind.config.js` at the root of your project.

lib/rules/classnames-order.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ module.exports = {
4444
items: { type: 'string', minLength: 0 },
4545
uniqueItems: true,
4646
},
47+
ignoredKeys: {
48+
type: 'array',
49+
items: { type: 'string', minLength: 0 },
50+
uniqueItems: true,
51+
},
4752
config: {
4853
// default: 'tailwind.config.js',
4954
type: ['string', 'object'],

lib/rules/enforces-negative-arbitrary-values.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ module.exports = {
4040
items: { type: 'string', minLength: 0 },
4141
uniqueItems: true,
4242
},
43+
ignoredKeys: {
44+
type: 'array',
45+
items: { type: 'string', minLength: 0 },
46+
uniqueItems: true,
47+
},
4348
config: {
4449
// default: 'tailwind.config.js',
4550
type: ['string', 'object'],

lib/rules/enforces-shorthand.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ module.exports = {
4141
items: { type: 'string', minLength: 0 },
4242
uniqueItems: true,
4343
},
44+
ignoredKeys: {
45+
type: 'array',
46+
items: { type: 'string', minLength: 0 },
47+
uniqueItems: true,
48+
},
4449
config: {
4550
// default: 'tailwind.config.js',
4651
type: ['string', 'object'],

0 commit comments

Comments
 (0)