@bull-js/eslint-plugin 0.0.0-stage → 0.3.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/LICENSE +21 -0
- package/README.md +21 -2
- package/dist/index.d.ts +13 -0
- package/dist/index.js +87 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bull contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @bull-js/eslint-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Bull](https://github.com/nicolasandradedesarrollosit/bull.js)'s file-level MVVM rules, underlined in
|
|
4
|
+
your editor as you type. Same code and same messages as `bull build`.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install -D @bull-js/eslint-plugin eslint
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
// eslint.config.js
|
|
12
|
+
import bull from "@bull-js/eslint-plugin";
|
|
13
|
+
|
|
14
|
+
export default [...bull.configs.recommended];
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Project-wide rules (missing layers, cycles, the composition root, the config itself) need the whole
|
|
18
|
+
project, so they run in `bull check` and `bull build` instead.
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Rule, Linter } from 'eslint';
|
|
2
|
+
|
|
3
|
+
declare const rules: Record<string, Rule.RuleModule>;
|
|
4
|
+
declare const plugin: {
|
|
5
|
+
meta: {
|
|
6
|
+
name: string;
|
|
7
|
+
version: string;
|
|
8
|
+
};
|
|
9
|
+
rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
configs: Record<string, Linter.Config[]>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { plugin as default, rules };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
extractFacts,
|
|
4
|
+
RULE_LIST,
|
|
5
|
+
resolveConfig,
|
|
6
|
+
runFileRules
|
|
7
|
+
} from "@bull-js/core";
|
|
8
|
+
import tsParser from "@typescript-eslint/parser";
|
|
9
|
+
var configCache = /* @__PURE__ */ new Map();
|
|
10
|
+
var resultCache = /* @__PURE__ */ new WeakMap();
|
|
11
|
+
function configFor(context) {
|
|
12
|
+
const settings = context.settings?.bull ?? {};
|
|
13
|
+
const root = settings.root ?? context.cwd;
|
|
14
|
+
const key = JSON.stringify([root, settings]);
|
|
15
|
+
let config = configCache.get(key);
|
|
16
|
+
if (!config) {
|
|
17
|
+
config = resolveConfig(root, settings).config;
|
|
18
|
+
configCache.set(key, config);
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
function diagnosticsFor(context) {
|
|
23
|
+
const ast = context.sourceCode.ast;
|
|
24
|
+
let diagnostics = resultCache.get(ast);
|
|
25
|
+
if (!diagnostics) {
|
|
26
|
+
const facts = extractFacts(ast);
|
|
27
|
+
diagnostics = runFileRules(context.filename, facts, configFor(context));
|
|
28
|
+
resultCache.set(ast, diagnostics);
|
|
29
|
+
}
|
|
30
|
+
return diagnostics;
|
|
31
|
+
}
|
|
32
|
+
function createRule(meta) {
|
|
33
|
+
return {
|
|
34
|
+
meta: {
|
|
35
|
+
type: "problem",
|
|
36
|
+
docs: { description: `${meta.code}: ${meta.summary}` },
|
|
37
|
+
messages: { violation: "{{message}} {{fix}} ({{code}} \xB7 bull explain {{code}})" },
|
|
38
|
+
schema: []
|
|
39
|
+
},
|
|
40
|
+
create(context) {
|
|
41
|
+
return {
|
|
42
|
+
"Program:exit"() {
|
|
43
|
+
for (const d of diagnosticsFor(context)) {
|
|
44
|
+
if (d.code !== meta.code) continue;
|
|
45
|
+
const firstStep = meta.fix(d.data)[0] ?? "";
|
|
46
|
+
context.report({
|
|
47
|
+
messageId: "violation",
|
|
48
|
+
data: { message: d.message.replace(/`/g, "'"), fix: `\u2192 ${firstStep.replace(/`/g, "'")}`, code: d.code },
|
|
49
|
+
loc: d.range ? {
|
|
50
|
+
start: { line: d.range.start.line, column: d.range.start.column - 1 },
|
|
51
|
+
end: { line: d.range.end.line, column: d.range.end.column - 1 }
|
|
52
|
+
} : { line: 1, column: 0 }
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
var fileRules = RULE_LIST.filter((meta) => meta.scope === "file" && meta.category !== "config");
|
|
61
|
+
var rules = Object.fromEntries(
|
|
62
|
+
fileRules.map((meta) => [meta.slug, createRule(meta)])
|
|
63
|
+
);
|
|
64
|
+
var plugin = {
|
|
65
|
+
meta: { name: "@bull-js/eslint-plugin", version: "0.2.0" },
|
|
66
|
+
rules,
|
|
67
|
+
configs: {}
|
|
68
|
+
};
|
|
69
|
+
plugin.configs.recommended = [
|
|
70
|
+
{
|
|
71
|
+
name: "bull/recommended",
|
|
72
|
+
files: ["src/**/*.{ts,tsx,js,jsx}"],
|
|
73
|
+
languageOptions: {
|
|
74
|
+
parser: tsParser,
|
|
75
|
+
parserOptions: { ecmaFeatures: { jsx: true }, sourceType: "module" }
|
|
76
|
+
},
|
|
77
|
+
plugins: { bull: plugin },
|
|
78
|
+
rules: Object.fromEntries(
|
|
79
|
+
fileRules.map((meta) => [`bull/${meta.slug}`, meta.severity === "error" ? "error" : "warn"])
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
];
|
|
83
|
+
var index_default = plugin;
|
|
84
|
+
export {
|
|
85
|
+
index_default as default,
|
|
86
|
+
rules
|
|
87
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bull-js/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Bull's MVVM architecture rules, in your editor.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/nicolasandradedesarrollosit/bull.js#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/nicolasandradedesarrollosit/bull.js.git",
|
|
11
|
+
"directory": "packages/eslint-plugin"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/nicolasandradedesarrollosit/bull.js/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"eslint",
|
|
18
|
+
"eslintplugin",
|
|
19
|
+
"eslint-plugin",
|
|
20
|
+
"mvvm",
|
|
21
|
+
"architecture",
|
|
22
|
+
"react"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsup src/index.ts --format esm --dts --clean --external @bull-js/core"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"eslint": ">=9"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@bull-js/core": "^0.3.0",
|
|
48
|
+
"@typescript-eslint/parser": "^8.71.1"
|
|
49
|
+
}
|
|
50
|
+
}
|