eslint-plugin-hex-under 0.4.1 → 0.5.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 CHANGED
@@ -64,7 +64,6 @@ module.exports = [
64
64
  #### Experimental BigInteger Support
65
65
 
66
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
67
 
69
68
  ```js
70
69
  // eslint.config.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-hex-under",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "main": "src/eslint-plugin-hex-under.js",
5
5
  "scripts": {
6
6
  "lint": "prettier . --check && eslint .",
@@ -17,7 +17,7 @@
17
17
  "license": "MIT",
18
18
  "description": "This ESLint rule proves that hex numbers are less than a specified value.",
19
19
  "devDependencies": {
20
- "eslint": "10.0.2",
20
+ "eslint": "10.0.3",
21
21
  "prettier": "3.8.1"
22
22
  },
23
23
  "peerDependencies": {
@@ -1,60 +0,0 @@
1
- module.exports = {
2
- meta: {
3
- type: "suggestion",
4
- version: "0.0.1",
5
- defaultOptions: [
6
- {
7
- limit: 255,
8
- },
9
- ],
10
- docs: {
11
- description:
12
- "Proves that a hexadecimal bigint must be less than a specified value. Default is 255.",
13
- },
14
- fixable: "code",
15
- schema: [
16
- {
17
- type: "object",
18
- properties: {
19
- limit: {
20
- type: "integer",
21
- minimum: 1,
22
- },
23
- },
24
- additionalProperties: false,
25
- },
26
- ],
27
- messages: {
28
- valueOverGeneralBigInt:
29
- "This bigint must be less than or equal {{ limit }}. {{ overValue }} ({{ over255Raw }}) is greater than {{ limit }}.",
30
- },
31
- },
32
- create(context) {
33
- const limit = context.options[0]?.limit;
34
- return {
35
- onCodePathEnd: function (_codePath, node) {
36
- const tokens =
37
- node.tokens?.filter(
38
- (token) =>
39
- ["Numeric", "Identifier"].some((el) => el === token.type) &&
40
- token.value.startsWith("0x") &&
41
- token.value.endsWith("n"),
42
- ) || [];
43
- for (const token of tokens) {
44
- const value = parseInt(token.value);
45
- if (value > limit) {
46
- context.report({
47
- node: token,
48
- messageId: "valueOverGeneralBigInt",
49
- data: {
50
- limit: limit,
51
- over255Raw: token.value,
52
- overValue: value,
53
- },
54
- });
55
- }
56
- }
57
- },
58
- };
59
- },
60
- };
@@ -1,63 +0,0 @@
1
- module.exports = {
2
- meta: {
3
- type: "suggestion",
4
- version: "0.3.0",
5
- defaultOptions: [
6
- {
7
- limit: 255,
8
- },
9
- ],
10
- docs: {
11
- description:
12
- "Proves that a hexadecimal number must be less than a specified value. Default is 255.",
13
- },
14
- fixable: "code",
15
- schema: [
16
- {
17
- type: "object",
18
- properties: {
19
- limit: {
20
- type: "integer",
21
- minimum: 1,
22
- },
23
- },
24
- additionalProperties: false,
25
- },
26
- ],
27
- messages: {
28
- valueOverGeneral:
29
- "This number must be less than or equal {{ limit }}. {{ overValue }} ({{ over255Raw }}) is greater than {{ limit }}.",
30
- },
31
- },
32
- create(context) {
33
- const limit = context.options[0]?.limit;
34
- return {
35
- onCodePathEnd: function (_codePath, node) {
36
- const tokens =
37
- node.tokens?.filter(
38
- (token) =>
39
- ["Numeric", "Identifier"].some((el) => el === token.type) &&
40
- token.value.startsWith("0x") &&
41
- !token.value.endsWith("n"),
42
- ) || [];
43
- for (const token of tokens) {
44
- const value = parseInt(token.value);
45
- if (value > limit) {
46
- context.report({
47
- node: token,
48
- messageId: "valueOverGeneral",
49
- data: {
50
- limit: limit,
51
- over255Raw: token.value,
52
- overValue: value,
53
- },
54
- fix(fixer) {
55
- return fixer.replaceText(token, String(value));
56
- },
57
- });
58
- }
59
- }
60
- },
61
- };
62
- },
63
- };