ember-scoped-css 0.3.0 → 0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ember-scoped-css",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "ISC",
@@ -44,6 +44,7 @@
44
44
  "chai": "^4.3.7",
45
45
  "esbuild": "^0.17.17",
46
46
  "eslint": "^8.38.0",
47
+ "ember-template-lint": "^5.7.2",
47
48
  "mocha": "^10.2.0",
48
49
  "release-it": "^15.10.1",
49
50
  "release-it-lerna-changelog": "^5.0.0",
@@ -51,6 +52,7 @@
51
52
  "webpack": "^5.75.0"
52
53
  },
53
54
  "peerDependencies": {
55
+ "ember-template-lint": "^5.7.2",
54
56
  "webpack": "^5.0.0"
55
57
  },
56
58
  "publishConfig": {
@@ -0,0 +1,38 @@
1
+ import { Rule } from 'ember-template-lint';
2
+
3
+ class ScopedClassHelperRule extends Rule {
4
+ visitor() {
5
+ const checkScopedClass = function (node) {
6
+ if (node.path.original !== 'scoped-class') {
7
+ return;
8
+ }
9
+
10
+ if (node.params.length === 1) {
11
+ if (node.params[0].type !== 'StringLiteral') {
12
+ this.log({
13
+ message:
14
+ 'You cannot pass dynamic values to scoped-class helper. {{scoped-class "some-class"}}',
15
+ node,
16
+ });
17
+ }
18
+ } else {
19
+ this.log({
20
+ message:
21
+ 'At least one class is required to be passed to scoped-class helper. {{scoped-class "some-class"}}',
22
+ node,
23
+ });
24
+ }
25
+ };
26
+ return {
27
+ MustacheStatement: checkScopedClass,
28
+ SubExpression: checkScopedClass,
29
+ };
30
+ }
31
+ }
32
+
33
+ export default {
34
+ name: 'scoped-class-helper-plugin',
35
+ rules: {
36
+ 'scoped-class-helper': ScopedClassHelperRule,
37
+ },
38
+ };
@@ -24,7 +24,7 @@ describe('rewriteCss', function () {
24
24
  );
25
25
  });
26
26
 
27
- it.only('sudnt rewrite keyframes', function () {
27
+ it('sudnt rewrite keyframes', function () {
28
28
  const css = `
29
29
  @keyframes luna-view-navigation {
30
30
  100% {
@@ -0,0 +1,38 @@
1
+ import { generateRuleTests } from 'ember-template-lint';
2
+ import scopedClassHelperPlugin from '../src/template-lint/scoped-class-helper-plugin.js';
3
+ import assert from 'assert';
4
+
5
+ generateRuleTests({
6
+ name: 'scoped-class-helper',
7
+
8
+ groupMethodBefore: beforeEach,
9
+ groupingMethod: describe,
10
+ testMethod: it,
11
+ plugins: [scopedClassHelperPlugin],
12
+ config: true,
13
+ good: ['{{scoped-class "test"}}', '{{(scoped-class "test")}}'],
14
+ bad: [
15
+ {
16
+ template: '{{scoped-class}}',
17
+
18
+ verifyResults(results) {
19
+ assert.equal(results.length, 1);
20
+ assert.equal(
21
+ results[0].message,
22
+ 'At least one class is required to be passed to scoped-class helper. {{scoped-class "some-class"}}'
23
+ );
24
+ },
25
+ },
26
+ {
27
+ template: '{{scoped-class this.someClass}}',
28
+
29
+ verifyResults(results) {
30
+ assert.equal(results.length, 1);
31
+ assert.equal(
32
+ results[0].message,
33
+ 'You cannot pass dynamic values to scoped-class helper. {{scoped-class "some-class"}}'
34
+ );
35
+ },
36
+ },
37
+ ],
38
+ });