eslint-plugin-hex-under 0.3.1 → 0.4.0
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/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hex-under",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"main": "eslint-plugin-hex-under.js",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"main": "src/eslint-plugin-hex-under.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"lint": "prettier . --check && eslint .",
|
|
7
|
-
"test": "
|
|
8
|
-
"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"
|
|
9
10
|
},
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
"license": "MIT",
|
|
17
18
|
"description": "This ESLint rule proves that hex numbers are less than a specified value.",
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"eslint": "
|
|
20
|
-
"prettier": "3.
|
|
20
|
+
"eslint": "10.0.0",
|
|
21
|
+
"prettier": "3.8.1"
|
|
21
22
|
}
|
|
22
23
|
}
|
|
@@ -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,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
meta: {
|
|
3
3
|
type: "suggestion",
|
|
4
|
-
version: "0.
|
|
4
|
+
version: "0.3.0",
|
|
5
5
|
defaultOptions: [
|
|
6
6
|
{
|
|
7
7
|
limit: 255,
|
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
|
52
52
|
overValue: value,
|
|
53
53
|
},
|
|
54
54
|
fix(fixer) {
|
|
55
|
-
return fixer.replaceText(token, value);
|
|
55
|
+
return fixer.replaceText(token, String(value));
|
|
56
56
|
},
|
|
57
57
|
});
|
|
58
58
|
}
|
package/hex-under-bigint.test.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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/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
|