ember-scoped-css 3.2.0 → 3.4.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 +12 -5
- package/dist/cjs/all-DurjGbDW.cjs +1711 -0
- package/dist/cjs/all.cjs +1 -1
- package/dist/cjs/babel.cjs +1 -1
- package/dist/cjs/rollup.cjs +1 -1
- package/dist/cjs/vite.cjs +1 -1
- package/dist/runtime/test-support.js +5 -0
- package/dist/runtime/test-support.js.map +1 -1
- package/package.json +1 -1
- package/src/build/babel-plugin.js +1 -5
- package/src/build/babel-plugin.test.ts +113 -0
- package/src/build/template-plugin.js +36 -32
- package/src/lib/css/rewrite.js +9 -0
- package/src/lib/css/rewrite.test.ts +35 -1
- package/src/lib/renameClass.js +5 -0
- package/src/lib/rewriteHbs.classes.concat.test.ts +156 -0
- package/src/lib/rewriteHbs.classes.test.ts +28 -0
- package/src/lib/rewriteHbs.if.test.ts +168 -0
- package/src/lib/rewriteHbs.js +277 -38
- package/src/lib/rewriteHbs.scopedClass.test.ts +19 -0
- package/src/lib/rewriteHbs.unless.test.ts +63 -0
- package/src/template-lint/plugin.js +74 -6
- package/dist/cjs/all-DJjr6YEx.cjs +0 -1534
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { generateRuleTests, Rule } from 'ember-template-lint';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* `scoped-class` is the legacy hbs global; `scopedClass` is the form consumers
|
|
5
|
+
* import. Both compile through the same build-time rewrite, so both are subject
|
|
6
|
+
* to the same restrictions.
|
|
7
|
+
*/
|
|
8
|
+
const HELPER_NAMES = new Set(['scoped-class', 'scopedClass']);
|
|
9
|
+
|
|
3
10
|
class ScopedClassHelperRule extends Rule {
|
|
4
11
|
visitor() {
|
|
5
12
|
const checkScopedClass = function (node) {
|
|
6
|
-
|
|
13
|
+
const helperName = node.path.original;
|
|
14
|
+
|
|
15
|
+
if (!HELPER_NAMES.has(helperName)) {
|
|
7
16
|
return;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
if (node.params.length === 1) {
|
|
11
20
|
if (node.params[0].type !== 'StringLiteral') {
|
|
12
21
|
this.log({
|
|
13
|
-
message:
|
|
14
|
-
'You cannot pass dynamic values to scoped-class helper. {{scoped-class "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
22
|
+
message: `You cannot pass dynamic values to ${helperName} helper. {{${helperName} "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md`,
|
|
15
23
|
node,
|
|
16
24
|
});
|
|
17
25
|
}
|
|
18
26
|
} else {
|
|
19
27
|
this.log({
|
|
20
|
-
message:
|
|
21
|
-
'One positional param is required to be passed to scoped-class helper. {{scoped-class "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
28
|
+
message: `One positional param is required to be passed to ${helperName} helper. {{${helperName} "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md`,
|
|
22
29
|
node,
|
|
23
30
|
});
|
|
24
31
|
}
|
|
@@ -53,7 +60,13 @@ if (import.meta.vitest) {
|
|
|
53
60
|
testMethod: it,
|
|
54
61
|
plugins: [scopedClassHelperPlugin],
|
|
55
62
|
config: true,
|
|
56
|
-
good: [
|
|
63
|
+
good: [
|
|
64
|
+
'{{scoped-class "test"}}',
|
|
65
|
+
'{{(scoped-class "test")}}',
|
|
66
|
+
'{{scopedClass "test"}}',
|
|
67
|
+
'{{(scopedClass "test")}}',
|
|
68
|
+
'{{some-other-helper this.someClass}}',
|
|
69
|
+
],
|
|
57
70
|
bad: [
|
|
58
71
|
{
|
|
59
72
|
template: '{{scoped-class}}',
|
|
@@ -77,6 +90,61 @@ if (import.meta.vitest) {
|
|
|
77
90
|
);
|
|
78
91
|
},
|
|
79
92
|
},
|
|
93
|
+
{
|
|
94
|
+
template: '{{scopedClass}}',
|
|
95
|
+
|
|
96
|
+
verifyResults(results) {
|
|
97
|
+
assert.equal(results.length, 1);
|
|
98
|
+
assert.equal(
|
|
99
|
+
results[0].message,
|
|
100
|
+
'One positional param is required to be passed to scopedClass helper. {{scopedClass "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
template: '{{scopedClass this.someClass}}',
|
|
106
|
+
|
|
107
|
+
verifyResults(results) {
|
|
108
|
+
assert.equal(results.length, 1);
|
|
109
|
+
assert.equal(
|
|
110
|
+
results[0].message,
|
|
111
|
+
'You cannot pass dynamic values to scopedClass helper. {{scopedClass "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
template: '{{scopedClass "first" "second"}}',
|
|
117
|
+
|
|
118
|
+
verifyResults(results) {
|
|
119
|
+
assert.equal(results.length, 1);
|
|
120
|
+
assert.equal(
|
|
121
|
+
results[0].message,
|
|
122
|
+
'One positional param is required to be passed to scopedClass helper. {{scopedClass "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
123
|
+
);
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
template: '<Foo @class={{scopedClass this.someClass}} />',
|
|
128
|
+
|
|
129
|
+
verifyResults(results) {
|
|
130
|
+
assert.equal(results.length, 1);
|
|
131
|
+
assert.equal(
|
|
132
|
+
results[0].message,
|
|
133
|
+
'You cannot pass dynamic values to scopedClass helper. {{scopedClass "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
template: '<Foo @class={{if x (scopedClass this.someClass)}} />',
|
|
139
|
+
|
|
140
|
+
verifyResults(results) {
|
|
141
|
+
assert.equal(results.length, 1);
|
|
142
|
+
assert.equal(
|
|
143
|
+
results[0].message,
|
|
144
|
+
'You cannot pass dynamic values to scopedClass helper. {{scopedClass "some-class"}}. More info: https://github.com/soxhub/ember-scoped-css/blob/main/docs/lint-rules.md',
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
80
148
|
],
|
|
81
149
|
});
|
|
82
150
|
}
|