eslint-plugin-hex-under 1.2.2 → 1.2.4
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 +2 -1
- package/src/rules/binary-under.js +22 -14
- package/src/rules/hex-under.js +9 -12
- package/src/rules/octal-under.js +22 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-hex-under",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/eslint-plugin-hex-under.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@vitest/eslint-plugin": "1.6.12",
|
|
32
32
|
"bats": "1.13.0",
|
|
33
33
|
"eslint": "10.0.3",
|
|
34
|
+
"eslint-plugin-eslint-plugin": "7.3.2",
|
|
34
35
|
"prettier": "3.8.1",
|
|
35
36
|
"tinyexec": "1.0.4",
|
|
36
37
|
"vitest": "4.1.0"
|
|
@@ -3,20 +3,34 @@ const BINARY_REGEX_BIGINT = /^0[bB][01_]+n$/;
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
meta: {
|
|
6
|
-
version: '0.1.
|
|
6
|
+
version: '0.1.1',
|
|
7
7
|
type: 'suggestion',
|
|
8
8
|
docs: {
|
|
9
9
|
description: 'Ensures binary numbers do not exceed a limit.',
|
|
10
10
|
recommended: false,
|
|
11
11
|
},
|
|
12
|
+
defaultOptions: [
|
|
13
|
+
{
|
|
14
|
+
limit: 15,
|
|
15
|
+
skipBigInt: false,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
12
18
|
fixable: 'code',
|
|
13
19
|
schema: [
|
|
14
20
|
{
|
|
15
21
|
type: 'object',
|
|
16
22
|
properties: {
|
|
17
|
-
limit: {
|
|
18
|
-
|
|
23
|
+
limit: {
|
|
24
|
+
type: 'integer',
|
|
25
|
+
minimum: 0,
|
|
26
|
+
description: 'The maximum allowed value for binary literals.',
|
|
27
|
+
},
|
|
28
|
+
skipBigInt: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Whether to skip BigInt literals.',
|
|
31
|
+
},
|
|
19
32
|
},
|
|
33
|
+
description: 'Options for binary-under rule',
|
|
20
34
|
additionalProperties: false,
|
|
21
35
|
},
|
|
22
36
|
],
|
|
@@ -28,21 +42,15 @@ export default {
|
|
|
28
42
|
|
|
29
43
|
create(context) {
|
|
30
44
|
const [{ limit = 15, skipBigInt = false } = {}] = context.options;
|
|
31
|
-
let comments = [];
|
|
32
45
|
return {
|
|
33
|
-
Program(node) {
|
|
34
|
-
comments = node.comments || [];
|
|
35
|
-
},
|
|
36
46
|
'Literal[raw=/^0[bB][01_]+n?$/]'(node) {
|
|
37
47
|
const raw = node.raw;
|
|
38
48
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
});
|
|
49
|
+
const sourceCode = context.sourceCode;
|
|
50
|
+
const line = node.loc.end.line;
|
|
51
|
+
const ignore =
|
|
52
|
+
sourceCode.lines[line - 2]?.startsWith('// ignore-binary-under') ||
|
|
53
|
+
/\/\/\s(ignore-binary-under)/.test(sourceCode.lines[line - 1]);
|
|
46
54
|
if (ignore) return;
|
|
47
55
|
|
|
48
56
|
const isBigInt = BINARY_REGEX_BIGINT.test(raw);
|
package/src/rules/hex-under.js
CHANGED
|
@@ -4,7 +4,7 @@ const HEX_REGEX_BIGINT = /^0[xX][0-9a-fA-F_]+n$/;
|
|
|
4
4
|
export default {
|
|
5
5
|
meta: {
|
|
6
6
|
type: 'suggestion',
|
|
7
|
-
version: '0.
|
|
7
|
+
version: '0.6.0',
|
|
8
8
|
defaultOptions: [
|
|
9
9
|
{
|
|
10
10
|
limit: 255,
|
|
@@ -24,11 +24,14 @@ export default {
|
|
|
24
24
|
limit: {
|
|
25
25
|
type: 'integer',
|
|
26
26
|
minimum: 0,
|
|
27
|
+
description: 'The maximum allowed value for hexadecimal literals.',
|
|
27
28
|
},
|
|
28
29
|
skipBigInt: {
|
|
29
30
|
type: 'boolean',
|
|
31
|
+
description: 'Whether to skip BigInt literals.',
|
|
30
32
|
},
|
|
31
33
|
},
|
|
34
|
+
description: 'Options for hex-under rule',
|
|
32
35
|
additionalProperties: false,
|
|
33
36
|
},
|
|
34
37
|
],
|
|
@@ -40,21 +43,15 @@ export default {
|
|
|
40
43
|
|
|
41
44
|
create(context) {
|
|
42
45
|
const [{ limit = 255, skipBigInt = false } = {}] = context.options;
|
|
43
|
-
let comments = [];
|
|
44
46
|
return {
|
|
45
|
-
Program(node) {
|
|
46
|
-
comments = node.comments || [];
|
|
47
|
-
},
|
|
48
47
|
'Literal[raw=/^0[xX][0-9a-fA-F_]+n?$/]'(node) {
|
|
49
48
|
const raw = node.raw;
|
|
50
49
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
-
});
|
|
50
|
+
const sourceCode = context.sourceCode;
|
|
51
|
+
const line = node.loc.end.line;
|
|
52
|
+
const ignore =
|
|
53
|
+
sourceCode.lines[line - 2]?.startsWith('// ignore-hex-under') ||
|
|
54
|
+
/\/\/\s(ignore-hex-under)/.test(sourceCode.lines[line - 1]);
|
|
58
55
|
if (ignore) return;
|
|
59
56
|
|
|
60
57
|
const isHexBigInt = HEX_REGEX_BIGINT.test(raw);
|
package/src/rules/octal-under.js
CHANGED
|
@@ -3,20 +3,34 @@ const OCTAL_REGEX_BIGINT = /^0[oO]?[0-7_]+n$/;
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
meta: {
|
|
6
|
-
version: '0.
|
|
6
|
+
version: '0.2.0',
|
|
7
7
|
type: 'suggestion',
|
|
8
8
|
docs: {
|
|
9
9
|
description: 'Ensures octal numbers do not exceed a limit.',
|
|
10
10
|
recommended: false,
|
|
11
11
|
},
|
|
12
|
+
defaultOptions: [
|
|
13
|
+
{
|
|
14
|
+
limit: 511,
|
|
15
|
+
skipBigInt: false,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
12
18
|
fixable: 'code',
|
|
13
19
|
schema: [
|
|
14
20
|
{
|
|
15
21
|
type: 'object',
|
|
16
22
|
properties: {
|
|
17
|
-
limit: {
|
|
18
|
-
|
|
23
|
+
limit: {
|
|
24
|
+
type: 'integer',
|
|
25
|
+
minimum: 0,
|
|
26
|
+
description: 'The maximum allowed value for octal literals.',
|
|
27
|
+
},
|
|
28
|
+
skipBigInt: {
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
description: 'Whether to skip BigInt literals.',
|
|
31
|
+
},
|
|
19
32
|
},
|
|
33
|
+
description: 'Options for octal-under rule',
|
|
20
34
|
additionalProperties: false,
|
|
21
35
|
},
|
|
22
36
|
],
|
|
@@ -28,21 +42,15 @@ export default {
|
|
|
28
42
|
|
|
29
43
|
create(context) {
|
|
30
44
|
const [{ limit = 511, skipBigInt = false } = {}] = context.options;
|
|
31
|
-
let comments = [];
|
|
32
45
|
return {
|
|
33
|
-
Program(node) {
|
|
34
|
-
comments = node.comments || [];
|
|
35
|
-
},
|
|
36
46
|
'Literal[raw=/^0[oO]?[0-7_]+n?$/]'(node) {
|
|
37
47
|
const raw = node.raw;
|
|
38
48
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
45
|
-
});
|
|
49
|
+
const sourceCode = context.sourceCode;
|
|
50
|
+
const line = node.loc.end.line;
|
|
51
|
+
const ignore =
|
|
52
|
+
sourceCode.lines[line - 2]?.startsWith('// ignore-octal-under') ||
|
|
53
|
+
/\/\/\s(ignore-octal-under)/.test(sourceCode.lines[line - 1]);
|
|
46
54
|
if (ignore) return;
|
|
47
55
|
|
|
48
56
|
if (
|