eslint-plugin-hex-under 0.3.0 → 0.3.1
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 -0
- package/hex-under-bigint.test.js +50 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -60,3 +60,26 @@ module.exports = [
|
|
|
60
60
|
},
|
|
61
61
|
];
|
|
62
62
|
```
|
|
63
|
+
|
|
64
|
+
#### Experimental BigInteger Support
|
|
65
|
+
|
|
66
|
+
There is a similar rule to prove for BigInteger hexadecimal numbers. You can enable it similar to the `hex-under` rule. The default limit is 255.
|
|
67
|
+
At the moment these found issues are not automatically fixable.
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// eslint.config.js
|
|
71
|
+
|
|
72
|
+
const eslintPluginHexUnder = require("eslint-plugin-hex-under");
|
|
73
|
+
|
|
74
|
+
module.exports = [
|
|
75
|
+
{
|
|
76
|
+
files: ["*.js"],
|
|
77
|
+
plugins: {
|
|
78
|
+
"hex-under": eslintPluginHexUnder,
|
|
79
|
+
},
|
|
80
|
+
rules: {
|
|
81
|
+
"hex-under/hex-under-bigint": "warn",
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { RuleTester } = require("eslint");
|
|
2
|
+
const hexUnderBigintRule = require("./hex-under-bigint");
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester({
|
|
5
|
+
languageOptions: {
|
|
6
|
+
ecmaVersion: 2022,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
ruleTester.run("hex-under-bigint", hexUnderBigintRule, {
|
|
11
|
+
valid: [
|
|
12
|
+
{
|
|
13
|
+
options: [{ limit: 255 }],
|
|
14
|
+
code: "const foo = 0xffn;",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
options: [{ limit: 15 }],
|
|
18
|
+
code: "const foo = 0xfn;",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
options: [{ limit: 256 }],
|
|
22
|
+
code: "const foo = 0x100n;",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
options: [{ limit: 255 }],
|
|
26
|
+
code: "let foo = 0xffn;",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
options: [{ limit: 256 }],
|
|
30
|
+
code: "var foo = 0xffn;",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
code: "function func() {\n return 0xffn;\n}",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
code: "functionA(0xefn);",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
code: "const func = () => 0xabn;",
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
invalid: [
|
|
43
|
+
{
|
|
44
|
+
code: "const foo = 0x100n;",
|
|
45
|
+
errors: 1,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
console.log("All tests passed!");
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hex-under",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"main": "eslint-plugin-hex-under.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "prettier . --check && eslint .",
|
|
7
|
-
"test": "node hex-under.test.js"
|
|
7
|
+
"test": "node hex-under.test.js",
|
|
8
|
+
"test:bigint": "node hex-under-bigint.test.js"
|
|
8
9
|
},
|
|
9
10
|
"repository": {
|
|
10
11
|
"type": "git",
|