eslint-plugin-decimal-system 1.0.5 → 1.0.7
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 +12 -24
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +2 -0
- package/dist/index.d.ts +3 -22
- package/dist/index.js +12 -6
- package/dist/rules/decimal-system-only.js +1 -1
- package/dist/test/decimal-system-only.test.d.ts +1 -0
- package/dist/test/decimal-system-only.test.js +38 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +2 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -23,23 +23,27 @@ Peer dependency:
|
|
|
23
23
|
npm install --save-dev eslint
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
### What the plugin exports
|
|
27
|
+
|
|
28
|
+
- default → plugin (contains `rules` and `configs`)
|
|
29
|
+
|
|
30
|
+
- named export → `rules`
|
|
31
|
+
|
|
26
32
|
### Usage
|
|
27
|
-
ESLint 9
|
|
33
|
+
ESLint 9
|
|
28
34
|
```js
|
|
35
|
+
import { defineConfig } from "eslint/config";
|
|
29
36
|
import decimal from "eslint-plugin-decimal-system";
|
|
30
37
|
|
|
31
|
-
export default [
|
|
32
|
-
{
|
|
33
|
-
plugins: {
|
|
34
|
-
decimal,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
38
|
+
export default defineConfig([
|
|
37
39
|
...decimal.configs.recommended,
|
|
38
|
-
]
|
|
40
|
+
])
|
|
41
|
+
|
|
39
42
|
```
|
|
40
43
|
|
|
41
44
|
Or enable manually:
|
|
42
45
|
```js
|
|
46
|
+
import decimal from "eslint-plugin-decimal-system";
|
|
43
47
|
|
|
44
48
|
export default [
|
|
45
49
|
{
|
|
@@ -50,22 +54,6 @@ export default [
|
|
|
50
54
|
},
|
|
51
55
|
];
|
|
52
56
|
```
|
|
53
|
-
### Legacy Config (.eslintrc)
|
|
54
|
-
```js
|
|
55
|
-
{
|
|
56
|
-
"extends": ["plugin:decimal/recommended"]
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Or:
|
|
61
|
-
```js
|
|
62
|
-
{
|
|
63
|
-
"plugins": ["decimal"],
|
|
64
|
-
"rules": {
|
|
65
|
-
"decimal/decimal-system-only": "error"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
57
|
|
|
70
58
|
### Rule Details
|
|
71
59
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
};
|
|
6
|
-
export declare const rules: {
|
|
7
|
-
"decimal-system-only": import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
8
|
-
};
|
|
9
|
-
export declare const configs: {
|
|
10
|
-
recommended: {
|
|
11
|
-
plugins: {
|
|
12
|
-
decimal: {
|
|
13
|
-
rules: {
|
|
14
|
-
"decimal-system-only": import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
rules: {
|
|
19
|
-
"decimal/decimal-system-only": string;
|
|
20
|
-
};
|
|
21
|
-
}[];
|
|
22
|
-
};
|
|
1
|
+
import { Plugin } from "./types/index.js";
|
|
2
|
+
declare const plugin: Plugin;
|
|
3
|
+
export declare const rules: Record<string, import("@typescript-eslint/utils/ts-eslint").RuleModule<string, unknown[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>>;
|
|
23
4
|
export default plugin;
|
package/dist/index.js
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
|
+
import { RULE_NAME } from "./constants/index.js";
|
|
1
2
|
import decimalSystemOnly from "./rules/decimal-system-only.js";
|
|
2
3
|
const plugin = {
|
|
4
|
+
meta: {
|
|
5
|
+
name: "eslint-plugin-decimal-system",
|
|
6
|
+
version: "1.0.7",
|
|
7
|
+
},
|
|
3
8
|
rules: {
|
|
4
|
-
|
|
9
|
+
[RULE_NAME]: decimalSystemOnly,
|
|
5
10
|
},
|
|
11
|
+
configs: {},
|
|
6
12
|
};
|
|
7
13
|
export const rules = plugin.rules;
|
|
8
|
-
|
|
14
|
+
Object.assign(plugin.configs, {
|
|
9
15
|
recommended: [
|
|
10
16
|
{
|
|
11
17
|
plugins: {
|
|
12
18
|
decimal: plugin,
|
|
13
19
|
},
|
|
14
20
|
rules: {
|
|
15
|
-
|
|
21
|
+
[`decimal/${RULE_NAME}`]: "error",
|
|
16
22
|
},
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
};
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
});
|
|
20
26
|
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RuleTester } from '@typescript-eslint/rule-tester';
|
|
2
|
+
import * as vitest from 'vitest';
|
|
3
|
+
import rule from '../rules/decimal-system-only.js';
|
|
4
|
+
RuleTester.afterAll = vitest.afterAll;
|
|
5
|
+
RuleTester.it = vitest.it;
|
|
6
|
+
RuleTester.itOnly = vitest.it.only;
|
|
7
|
+
RuleTester.describe = vitest.describe;
|
|
8
|
+
const ruleTester = new RuleTester({
|
|
9
|
+
languageOptions: {
|
|
10
|
+
ecmaVersion: "latest",
|
|
11
|
+
sourceType: "module",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
ruleTester.run('decimalRule', rule, {
|
|
15
|
+
valid: [
|
|
16
|
+
"const a = 10;",
|
|
17
|
+
"const b = 42n;",
|
|
18
|
+
"const c = 0;",
|
|
19
|
+
],
|
|
20
|
+
invalid: [
|
|
21
|
+
{
|
|
22
|
+
code: "const a = 0xFF;",
|
|
23
|
+
errors: [{ messageId: "unexpected" }],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
code: "const a = 0b1010;",
|
|
27
|
+
errors: [{ messageId: "unexpected" }],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
code: "const a = 0o755;",
|
|
31
|
+
errors: [{ messageId: "unexpected" }],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
code: "const a = 0xFFn;",
|
|
35
|
+
errors: [{ messageId: "unexpected" }],
|
|
36
|
+
},
|
|
37
|
+
]
|
|
38
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
import type { RuleModule } from "@typescript-eslint/utils/ts-eslint";
|
|
3
|
+
export interface Plugin {
|
|
4
|
+
meta: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
};
|
|
8
|
+
rules: Record<string, RuleModule<string, unknown[]>>;
|
|
9
|
+
configs: Record<string, Linter.Config[]>;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-decimal-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "ESLint plugin that allows only decimal numeric literals",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"eslint": ">=9 <11"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@types/eslint": "^9.0.0",
|
|
27
|
+
"@typescript-eslint/rule-tester": "^8.56.1",
|
|
27
28
|
"@typescript-eslint/utils": "^8.56.1",
|
|
28
|
-
"
|
|
29
|
+
"typescript": "^5.9.3",
|
|
30
|
+
"vitest": "^4.0.18"
|
|
29
31
|
},
|
|
30
32
|
"scripts": {
|
|
33
|
+
"test": "vitest",
|
|
31
34
|
"build": "tsc",
|
|
32
35
|
"prepare": "npm run build"
|
|
33
36
|
}
|