@plumeria/eslint-plugin 17.0.1 → 18.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/rules/no-inline-object.js +10 -6
- package/dist/util/style-prop.d.ts +1 -1
- package/dist/util/style-prop.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ export default [plumeria.configs.recommended];
|
|
|
30
30
|
## Configuring the styling prop
|
|
31
31
|
|
|
32
32
|
Both `props-require-import` and `no-mixed-styling-props` need to know which JSX
|
|
33
|
-
prop carries styles. It is `
|
|
33
|
+
prop carries styles. It is `classStyle` unless you changed it, so most projects
|
|
34
34
|
configure nothing.
|
|
35
35
|
|
|
36
36
|
If you did rename it — via `styleProp` on `withPlumeria` or on the unplugin
|
|
@@ -81,7 +81,7 @@ Disallow destructuring APIs.
|
|
|
81
81
|
|
|
82
82
|
### no-inline-object
|
|
83
83
|
|
|
84
|
-
Disallow passing inline object to `
|
|
84
|
+
Disallow passing inline object to `classStyle`, `css.use()` and `css.variants()`. Only compiled styles from `css.create()` are allowed.
|
|
85
85
|
|
|
86
86
|
### no-inner-call
|
|
87
87
|
|
|
@@ -94,7 +94,7 @@ Disallow invalid selector inside `css.create()` and `css.keyframes()` and `css.v
|
|
|
94
94
|
|
|
95
95
|
### no-mixed-styling-props
|
|
96
96
|
|
|
97
|
-
Disallow mixing the styling prop with `className` or `style`. `
|
|
97
|
+
Disallow mixing the styling prop with `className` or `style`. `classStyle` can handle both `className` and `style`.
|
|
98
98
|
|
|
99
99
|
Accepts `{ styleProp }`; see [Configuring the styling prop](#configuring-the-styling-prop).
|
|
100
100
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.noInlineObject = void 0;
|
|
4
|
+
const style_prop_1 = require("../util/style-prop");
|
|
4
5
|
function isPlumeriaMemberCall(node, aliases, method) {
|
|
5
6
|
const callee = node.callee;
|
|
6
7
|
if (callee.type === 'MemberExpression') {
|
|
@@ -20,16 +21,17 @@ exports.noInlineObject = {
|
|
|
20
21
|
meta: {
|
|
21
22
|
type: 'problem',
|
|
22
23
|
docs: {
|
|
23
|
-
description: 'Disallow inline objects in
|
|
24
|
+
description: 'Disallow inline objects in the styling prop and css.use',
|
|
24
25
|
},
|
|
25
26
|
messages: {
|
|
26
|
-
|
|
27
|
+
noInlineObjectInStyleProp: 'Do not pass inline objects to "{{prop}}". It only accepts compiled styles from css.create().',
|
|
27
28
|
noInlineObjectInCssUse: 'Do not pass inline objects to css.use(). It only accepts compiled styles from css.create().',
|
|
28
29
|
noInlineObjectInCssVariants: 'Do not pass inline objects to css.variants(). It only accepts compiled styles from css.create().',
|
|
29
30
|
},
|
|
30
|
-
schema:
|
|
31
|
+
schema: style_prop_1.stylePropSchema,
|
|
31
32
|
},
|
|
32
33
|
create(context) {
|
|
34
|
+
const styleProp = (0, style_prop_1.resolveStyleProp)(context);
|
|
33
35
|
const plumeriaAliases = {};
|
|
34
36
|
return {
|
|
35
37
|
ImportDeclaration(node) {
|
|
@@ -53,14 +55,15 @@ exports.noInlineObject = {
|
|
|
53
55
|
},
|
|
54
56
|
JSXAttribute(node) {
|
|
55
57
|
if (node.name.type === 'JSXIdentifier' &&
|
|
56
|
-
node.name.name ===
|
|
58
|
+
node.name.name === styleProp) {
|
|
57
59
|
const value = node.value;
|
|
58
60
|
if (value?.type === 'JSXExpressionContainer') {
|
|
59
61
|
const expr = value.expression;
|
|
60
62
|
if (expr.type === 'ObjectExpression') {
|
|
61
63
|
context.report({
|
|
62
64
|
node: expr,
|
|
63
|
-
messageId: '
|
|
65
|
+
messageId: 'noInlineObjectInStyleProp',
|
|
66
|
+
data: { prop: styleProp },
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
else if (expr.type === 'ArrayExpression') {
|
|
@@ -68,7 +71,8 @@ exports.noInlineObject = {
|
|
|
68
71
|
if (el?.type === 'ObjectExpression') {
|
|
69
72
|
context.report({
|
|
70
73
|
node: el,
|
|
71
|
-
messageId: '
|
|
74
|
+
messageId: 'noInlineObjectInStyleProp',
|
|
75
|
+
data: { prop: styleProp },
|
|
72
76
|
});
|
|
73
77
|
}
|
|
74
78
|
});
|
package/dist/util/style-prop.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.stylePropSchema = exports.DEFAULT_STYLE_PROP = void 0;
|
|
4
4
|
exports.resolveStyleProp = resolveStyleProp;
|
|
5
|
-
exports.DEFAULT_STYLE_PROP = '
|
|
5
|
+
exports.DEFAULT_STYLE_PROP = 'classStyle';
|
|
6
6
|
exports.stylePropSchema = [
|
|
7
7
|
{
|
|
8
8
|
type: 'object',
|