eslint-plugin-hex-under 0.3.0 → 0.3.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
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
|
+
```
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hex-under",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"main": "eslint-plugin-hex-under.js",
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"main": "src/eslint-plugin-hex-under.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "prettier . --check && eslint .",
|
|
7
|
-
"test": "
|
|
7
|
+
"test": "npm run test:hex-under && npm run test:bigint",
|
|
8
|
+
"test:hex-under": "node test/hex-under.test.js",
|
|
9
|
+
"test:bigint": "node test/hex-under-bigint.test.js"
|
|
8
10
|
},
|
|
9
11
|
"repository": {
|
|
10
12
|
"type": "git",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const hexUnderRule = require("./hex-under");
|
|
2
|
-
const hexUnderBigintRule = require("./hex-under-bigint");
|
|
1
|
+
const hexUnderRule = require("./rules/hex-under");
|
|
2
|
+
const hexUnderBigintRule = require("./rules/hex-under-bigint");
|
|
3
3
|
const plugin = {
|
|
4
4
|
rules: {
|
|
5
5
|
"hex-under": hexUnderRule,
|
package/hex-under.test.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const { RuleTester } = require("eslint");
|
|
2
|
-
const hexUnderRule = require("./hex-under");
|
|
3
|
-
|
|
4
|
-
const ruleTester = new RuleTester({
|
|
5
|
-
languageOptions: { ecmaVersion: 2015 },
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
ruleTester.run("hex-under", hexUnderRule, {
|
|
9
|
-
valid: [
|
|
10
|
-
{
|
|
11
|
-
options: [{ limit: 255 }],
|
|
12
|
-
code: "const foo = 0xff;",
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
options: [{ limit: 15 }],
|
|
16
|
-
code: "const foo = 0xf;",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
options: [{ limit: 256 }],
|
|
20
|
-
code: "const foo = 0x100;",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
options: [{ limit: 255 }],
|
|
24
|
-
code: "let foo = 0xff;",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
options: [{ limit: 256 }],
|
|
28
|
-
code: "var foo = 0xff;",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
code: "function func() {\n return 0xff;\n}",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
code: "functionA(0xef);",
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
code: "const func = () => 0xab;",
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
invalid: [
|
|
41
|
-
{
|
|
42
|
-
code: "const foo = 0x100;",
|
|
43
|
-
output: "const foo = 256;",
|
|
44
|
-
errors: 1,
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
code: "let foo = 0x100;",
|
|
48
|
-
output: "let foo = 256;",
|
|
49
|
-
errors: 1,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
code: "var foo = 0x100;",
|
|
53
|
-
output: "var foo = 256;",
|
|
54
|
-
errors: 1,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
code: "function func() {\n return 0x100;\n}",
|
|
58
|
-
output: "function func() {\n return 256;\n}",
|
|
59
|
-
errors: 1,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
code: "functionA(0x1234);",
|
|
63
|
-
output: "functionA(4660);",
|
|
64
|
-
errors: 1,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
code: "const func = () => 0xabc;",
|
|
68
|
-
output: "const func = () => 2748;",
|
|
69
|
-
errors: 1,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
console.log("All tests passed!");
|
|
File without changes
|
|
File without changes
|