eslint-plugin-hex-under 1.11.1 → 1.11.3
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 +23 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,18 +23,18 @@ This can lead to:
|
|
|
23
23
|
|
|
24
24
|
The plugin provides three independent rules:
|
|
25
25
|
|
|
26
|
-
| Rule
|
|
27
|
-
|
|
28
|
-
| hex-under/hex-under
|
|
29
|
-
| hex-under/binary-under |
|
|
30
|
-
| hex-under/octal-under |
|
|
26
|
+
| Rule | Format | Default limit |
|
|
27
|
+
| ---------------------- | ----------- | ------------- |
|
|
28
|
+
| hex-under/hex-under | Hexadecimal | 0xff (255) |
|
|
29
|
+
| hex-under/binary-under | Binary | 0b1111 (15) |
|
|
30
|
+
| hex-under/octal-under | Octal | 0o777 (511) |
|
|
31
31
|
|
|
32
32
|
The configured limit is inclusive.
|
|
33
33
|
|
|
34
34
|
For example, with the default hexadecimal limit of 255:
|
|
35
35
|
|
|
36
36
|
```js
|
|
37
|
-
const a = 0xff;
|
|
37
|
+
const a = 0xff; // OK: 255
|
|
38
38
|
const b = 0x100; // Error: 256
|
|
39
39
|
```
|
|
40
40
|
|
|
@@ -60,18 +60,9 @@ export default [
|
|
|
60
60
|
'hex-under': eslintPluginHexUnder,
|
|
61
61
|
},
|
|
62
62
|
rules: {
|
|
63
|
-
'hex-under/hex-under': [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
'hex-under/octal-under': [
|
|
68
|
-
'error',
|
|
69
|
-
{ limit: 511, checkBigInt: true },
|
|
70
|
-
],
|
|
71
|
-
'hex-under/binary-under': [
|
|
72
|
-
'error',
|
|
73
|
-
{ limit: 15, checkBigInt: true },
|
|
74
|
-
],
|
|
63
|
+
'hex-under/hex-under': ['error', { limit: 255, checkBigInt: true }],
|
|
64
|
+
'hex-under/octal-under': ['error', { limit: 511, checkBigInt: true }],
|
|
65
|
+
'hex-under/binary-under': ['error', { limit: 15, checkBigInt: true }],
|
|
75
66
|
},
|
|
76
67
|
},
|
|
77
68
|
];
|
|
@@ -103,8 +94,11 @@ function add(a, b) {
|
|
|
103
94
|
const binary = 0b1111; // 15
|
|
104
95
|
|
|
105
96
|
const octal = 0o377; // 255
|
|
97
|
+
```
|
|
106
98
|
|
|
107
99
|
Invalid with default limits
|
|
100
|
+
|
|
101
|
+
```js
|
|
108
102
|
const signal = 0x21b; // 539
|
|
109
103
|
|
|
110
104
|
const func = () => 0xabc; // 2748
|
|
@@ -186,7 +180,7 @@ BigInt literals can optionally be checked using the checkBigInt option.
|
|
|
186
180
|
By default:
|
|
187
181
|
|
|
188
182
|
```js
|
|
189
|
-
checkBigInt: true
|
|
183
|
+
checkBigInt: true;
|
|
190
184
|
```
|
|
191
185
|
|
|
192
186
|
For example:
|
|
@@ -200,7 +194,7 @@ With checkBigInt: true, this literal is checked against the configured limit.
|
|
|
200
194
|
If you don't want BigInt literals to be checked, set:
|
|
201
195
|
|
|
202
196
|
```js
|
|
203
|
-
checkBigInt: false
|
|
197
|
+
checkBigInt: false;
|
|
204
198
|
```
|
|
205
199
|
|
|
206
200
|
For example:
|
|
@@ -225,20 +219,20 @@ const mask = 0xdead_beefn;
|
|
|
225
219
|
|
|
226
220
|
## Rules
|
|
227
221
|
|
|
228
|
-
| Rule |
|
|
229
|
-
|
|
230
|
-
| hex-under/hex-under
|
|
231
|
-
| hex-under/binary-under |
|
|
232
|
-
| hex-under/octal-under
|
|
222
|
+
| Rule | Description |
|
|
223
|
+
| ---------------------- | ----------------------------------- |
|
|
224
|
+
| hex-under/hex-under | Limits hexadecimal numeric literals |
|
|
225
|
+
| hex-under/binary-under | Limits binary numeric literals |
|
|
226
|
+
| hex-under/octal-under | Limits octal numeric literals |
|
|
233
227
|
|
|
234
228
|
Each rule can be configured independently.
|
|
235
229
|
|
|
236
230
|
## Options
|
|
237
231
|
|
|
238
|
-
| Option
|
|
239
|
-
|
|
240
|
-
| limit
|
|
241
|
-
|checkBigInt |
|
|
232
|
+
| Option | Type | Default | Description |
|
|
233
|
+
| ----------- | ------- | --------------- | ----------------------------------------- |
|
|
234
|
+
| limit | number | Format-specific | Maximum allowed numeric value |
|
|
235
|
+
| checkBigInt | boolean | true | Whether BigInt literals should be checked |
|
|
242
236
|
|
|
243
237
|
The limit is inclusive. A literal equal to the limit is valid; a literal greater than the limit is reported.
|
|
244
238
|
|
package/package.json
CHANGED