@d-zero/stylelint-rules 5.0.0-alpha.12 → 5.0.0-alpha.14

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.
@@ -34,6 +34,9 @@ export default createRule({
34
34
  }
35
35
  root.walkDecls((decl) => {
36
36
  const nodes = getValueType(decl);
37
+ if (nodes === null) {
38
+ return;
39
+ }
37
40
  for (const node of nodes) {
38
41
  if (!node.valueType) {
39
42
  continue;
@@ -1,6 +1,9 @@
1
1
  import CSSTree from '@d-zero/csstree-scss-syntax';
2
2
  import postcssValueParser from 'postcss-value-parser';
3
3
  export function getValueType(decl) {
4
+ if (decl.prop.startsWith('$')) {
5
+ return null;
6
+ }
4
7
  return _getValueType(decl.prop, decl.value);
5
8
  }
6
9
  function _getValueType(prop, value) {
@@ -14,7 +17,7 @@ function _getValueType(prop, value) {
14
17
  const values = valueAst.nodes.filter((node) => node.type === 'string' || node.type === 'function' || node.type === 'word');
15
18
  const props = cssTreeDecl.matched;
16
19
  if (props === null) {
17
- throw cssTreeDecl.error;
20
+ return null;
18
21
  }
19
22
  const valueTypes = props.match.map((node) => getValueNode(node).syntax.name);
20
23
  return values.map((value, i) => {
@@ -6,7 +6,7 @@ function p(css) {
6
6
  const rule = root.first;
7
7
  const decl = rule.first;
8
8
  const nodeWithType = getValueType(decl);
9
- return nodeWithType.map((node) => node.valueType);
9
+ return nodeWithType?.map((node) => node.valueType) ?? null;
10
10
  }
11
11
  describe('getValueType', () => {
12
12
  test('flex', () => {
@@ -25,4 +25,7 @@ describe('getValueType', () => {
25
25
  test('SASS Variable', () => {
26
26
  expect(p('a { flex: 1 2 $basis }')).toEqual(['number', 'number', '$SASS_VARIABLE']);
27
27
  });
28
+ test('SASS Variable Definition', () => {
29
+ expect(p('a { $var: value }')).toEqual(null);
30
+ });
28
31
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-zero/stylelint-rules",
3
- "version": "5.0.0-alpha.12",
3
+ "version": "5.0.0-alpha.14",
4
4
  "description": "Rules of Stylelint for D-ZERO",
5
5
  "repository": "https://github.com/d-zero-dev/linters.git",
6
6
  "author": "D-ZERO Co., Ltd.",
@@ -20,10 +20,10 @@
20
20
  "build": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@d-zero/csstree-scss-syntax": "5.0.0-alpha.12",
23
+ "@d-zero/csstree-scss-syntax": "5.0.0-alpha.14",
24
24
  "css-tree": "2.3.1",
25
25
  "postcss-value-parser": "4.2.0",
26
26
  "stylelint": "16.2.1"
27
27
  },
28
- "gitHead": "61145d5dfd13cff6630f882c5e11e3c5e3fb8d39"
28
+ "gitHead": "9ba13d8a3153a50f989d9a32fdddec4c43fbb8fa"
29
29
  }