stylelint-taro-rn 3.4.8 → 3.4.9

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.
@@ -11,11 +11,14 @@ var _stylePropertyNoUnknown = _interopRequireDefault(require("./style-property-n
11
11
 
12
12
  var _fontWeightNoIgnoredValues = _interopRequireDefault(require("./font-weight-no-ignored-values"));
13
13
 
14
+ var _lineHeightNoValueWithoutUnit = _interopRequireDefault(require("./line-height-no-value-without-unit"));
15
+
14
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
17
 
16
18
  var _default = {
17
19
  'font-weight-no-ignored-values': _fontWeightNoIgnoredValues.default,
18
20
  'css-property-no-unknown': _cssPropertyNoUnknown.default,
19
- 'style-property-no-unknown': _stylePropertyNoUnknown.default
21
+ 'style-property-no-unknown': _stylePropertyNoUnknown.default,
22
+ 'line-height-no-value-without-unit': _lineHeightNoValueWithoutUnit.default
20
23
  };
21
24
  exports.default = _default;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ exports.ruleName = exports.messages = void 0;
8
+
9
+ var _stylelint = require("stylelint");
10
+
11
+ var _utils = require("../../utils");
12
+
13
+ const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex');
14
+
15
+ const ruleName = (0, _utils.namespace)('line-height-no-value-without-unit');
16
+ exports.ruleName = ruleName;
17
+
18
+ const messages = _stylelint.utils.ruleMessages(ruleName, {
19
+ rejected: height => `Unexpected line-height "${height}", expect a value with units`
20
+ });
21
+
22
+ exports.messages = messages;
23
+ const lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px|PX|rem$))/;
24
+ const viewportUnitRe = /^([+-]?[0-9.]+)(vh|vw|vmin|vmax)$/;
25
+
26
+ function _default(actual) {
27
+ return function (root, result) {
28
+ const validOptions = _stylelint.utils.validateOptions(result, ruleName, {
29
+ actual
30
+ });
31
+
32
+ if (!validOptions) {
33
+ return;
34
+ }
35
+
36
+ root.walkDecls(/^line-height$/i, decl => {
37
+ if (lengthRe.test(decl.value) || viewportUnitRe.test(decl.value)) {
38
+ return;
39
+ }
40
+
41
+ const valueOffset = decl.value.indexOf(decl.value);
42
+ const index = declarationValueIndex(decl) + valueOffset;
43
+
44
+ _stylelint.utils.report({
45
+ message: messages.rejected(decl.value),
46
+ node: decl,
47
+ result,
48
+ ruleName,
49
+ index
50
+ });
51
+ });
52
+ };
53
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stylelint-taro-rn",
3
3
  "description": "A collection of React Native specific rules for stylelint",
4
- "version": "3.4.8",
4
+ "version": "3.4.9",
5
5
  "main": "dist/index.js",
6
6
  "files": [
7
7
  "dist",
@@ -73,5 +73,5 @@
73
73
  "dependencies": {
74
74
  "react-native-known-styling-properties": "^1.0.4"
75
75
  },
76
- "gitHead": "a025bcbb226ed3d01ed218c269a05d2e98109a46"
76
+ "gitHead": "6461e41999b9e2b26a7ec30b8979fa8b6e94198d"
77
77
  }
@@ -1,9 +1,11 @@
1
1
  import cssPropertyNoUnknown from './css-property-no-unknown'
2
2
  import stylePropertyNoUnknown from './style-property-no-unknown'
3
3
  import fontWeightNoIgnoredValues from './font-weight-no-ignored-values'
4
+ import lineHeightNoValueWithoutUnit from './line-height-no-value-without-unit'
4
5
 
5
6
  export default {
6
7
  'font-weight-no-ignored-values': fontWeightNoIgnoredValues,
7
8
  'css-property-no-unknown': cssPropertyNoUnknown,
8
- 'style-property-no-unknown': stylePropertyNoUnknown
9
+ 'style-property-no-unknown': stylePropertyNoUnknown,
10
+ 'line-height-no-value-without-unit': lineHeightNoValueWithoutUnit
9
11
  }
@@ -0,0 +1,40 @@
1
+ # line-height-no-value-without-unit
2
+
3
+ Disallow invalid `line-height` values on React Native.
4
+
5
+ ```css
6
+ .a {
7
+ line-height: 1;
8
+ }
9
+ /** ↑
10
+ * This value */
11
+ ```
12
+
13
+ More info:
14
+
15
+ - [taro/issues/11620](https://github.com/NervJS/taro/issues/11620)
16
+
17
+ ## Options
18
+
19
+ ### `true`
20
+
21
+ The following value or without units will be ignored:
22
+
23
+ ```css
24
+ .a {
25
+ line-height: 2;
26
+ }
27
+ ```
28
+
29
+ ```css
30
+ .a {
31
+ line-height: 100%;
32
+ }
33
+ ```
34
+
35
+ ```css
36
+ .a {
37
+ line-height: 100pt;
38
+ }
39
+ ```
40
+
@@ -0,0 +1,45 @@
1
+ import { utils } from 'stylelint'
2
+ import { namespace } from '../../utils'
3
+
4
+ const declarationValueIndex = require('stylelint/lib/utils/declarationValueIndex')
5
+
6
+ export const ruleName = namespace('line-height-no-value-without-unit')
7
+
8
+ export const messages = utils.ruleMessages(ruleName, {
9
+ rejected: height => `Unexpected line-height "${height}", expect a value with units`
10
+ })
11
+
12
+ const lengthRe = /^(0$|(?:[+-]?(?:\d*\.)?\d+(?:[Ee][+-]?\d+)?)(?=px|PX|rem$))/
13
+ const viewportUnitRe = /^([+-]?[0-9.]+)(vh|vw|vmin|vmax)$/
14
+
15
+ export default function (actual) {
16
+ return function (root, result) {
17
+ const validOptions = utils.validateOptions(result, ruleName, {
18
+ actual
19
+ })
20
+
21
+ if (!validOptions) {
22
+ return
23
+ }
24
+
25
+ root.walkDecls(/^line-height$/i, decl => {
26
+ if (
27
+ lengthRe.test(decl.value) ||
28
+ viewportUnitRe.test(decl.value)
29
+ ) {
30
+ return
31
+ }
32
+
33
+ const valueOffset = decl.value.indexOf(decl.value)
34
+ const index = declarationValueIndex(decl) + valueOffset
35
+
36
+ utils.report({
37
+ message: messages.rejected(decl.value),
38
+ node: decl,
39
+ result,
40
+ ruleName,
41
+ index
42
+ })
43
+ })
44
+ }
45
+ }