eslint-plugin-hex-under 1.11.1 → 1.11.2
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 +20 -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
|
];
|
|
@@ -186,7 +177,7 @@ BigInt literals can optionally be checked using the checkBigInt option.
|
|
|
186
177
|
By default:
|
|
187
178
|
|
|
188
179
|
```js
|
|
189
|
-
checkBigInt: true
|
|
180
|
+
checkBigInt: true;
|
|
190
181
|
```
|
|
191
182
|
|
|
192
183
|
For example:
|
|
@@ -200,7 +191,7 @@ With checkBigInt: true, this literal is checked against the configured limit.
|
|
|
200
191
|
If you don't want BigInt literals to be checked, set:
|
|
201
192
|
|
|
202
193
|
```js
|
|
203
|
-
checkBigInt: false
|
|
194
|
+
checkBigInt: false;
|
|
204
195
|
```
|
|
205
196
|
|
|
206
197
|
For example:
|
|
@@ -225,20 +216,20 @@ const mask = 0xdead_beefn;
|
|
|
225
216
|
|
|
226
217
|
## Rules
|
|
227
218
|
|
|
228
|
-
| Rule |
|
|
229
|
-
|
|
230
|
-
| hex-under/hex-under
|
|
231
|
-
| hex-under/binary-under |
|
|
232
|
-
| hex-under/octal-under
|
|
219
|
+
| Rule | Description |
|
|
220
|
+
| ---------------------- | ----------------------------------- |
|
|
221
|
+
| hex-under/hex-under | Limits hexadecimal numeric literals |
|
|
222
|
+
| hex-under/binary-under | Limits binary numeric literals |
|
|
223
|
+
| hex-under/octal-under | Limits octal numeric literals |
|
|
233
224
|
|
|
234
225
|
Each rule can be configured independently.
|
|
235
226
|
|
|
236
227
|
## Options
|
|
237
228
|
|
|
238
|
-
| Option
|
|
239
|
-
|
|
240
|
-
| limit
|
|
241
|
-
|checkBigInt |
|
|
229
|
+
| Option | Type | Default | Description |
|
|
230
|
+
| ----------- | ------- | --------------- | ----------------------------------------- |
|
|
231
|
+
| limit | number | Format-specific | Maximum allowed numeric value |
|
|
232
|
+
| checkBigInt | boolean | true | Whether BigInt literals should be checked |
|
|
242
233
|
|
|
243
234
|
The limit is inclusive. A literal equal to the limit is valid; a literal greater than the limit is reported.
|
|
244
235
|
|
package/package.json
CHANGED