eslint-plugin-boundaries 4.0.1 → 4.2.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/README.md +2 -1
- package/package.json +3 -1
- package/src/constants/settings.js +7 -0
- package/src/helpers/validations.js +7 -3
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ In words of Robert C. Martin, _"Software architecture is the art of drawing line
|
|
|
10
10
|
|
|
11
11
|
__This plugin ensures that your architecture boundaries are respected by the elements in your project__ checking the folders and files structure and the dependencies between them. __It is not a replacement for [eslint-plugin-import](https://www.npmjs.com/package/eslint-plugin-import), on the contrary, the combination of both plugins is recommended.__
|
|
12
12
|
|
|
13
|
-
By default, __the plugin works by checking `import` statements, but it is also able to analyze
|
|
13
|
+
By default, __the plugin works by checking `import` statements, but it is also able to analyze "require", "exports" and dynamic imports, and can be configured to check any other [AST nodes](https://eslint.org/docs/latest/extend/selectors)__. (_Read the [main rules overview](#main-rules-overview) and [configuration](#configuration) chapters for better comprehension_)
|
|
14
14
|
|
|
15
15
|
## Table of Contents
|
|
16
16
|
|
|
@@ -207,6 +207,7 @@ This setting allows to modify built-in default dependency nodes. By default, the
|
|
|
207
207
|
|
|
208
208
|
The setting should be an array of the following strings:
|
|
209
209
|
|
|
210
|
+
* `'require'`: analyze `require` statements.
|
|
210
211
|
* `'import'`: analyze `import` statements.
|
|
211
212
|
* `'export'`: analyze `export` statements.
|
|
212
213
|
* `'dynamic-import'`: analyze [dynamic import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import) statements.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-boundaries",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Eslint plugin checking architecture boundaries between elements",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"main": "index.js",
|
|
23
23
|
"scripts": {
|
|
24
|
+
"eslint": "eslint",
|
|
24
25
|
"lint": "eslint src *.js test",
|
|
25
26
|
"lint-staged": "lint-staged",
|
|
26
27
|
"test": "jest",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"eslint-config-prettier": "9.0.0",
|
|
46
47
|
"eslint-import-resolver-typescript": "3.6.1",
|
|
47
48
|
"eslint-plugin-prettier": "5.0.1",
|
|
49
|
+
"eslint-plugin-local-rules": "2.0.1",
|
|
48
50
|
"husky": "8.0.3",
|
|
49
51
|
"is-ci": "3.0.1",
|
|
50
52
|
"jest": "29.7.0",
|
|
@@ -41,6 +41,13 @@ module.exports = {
|
|
|
41
41
|
|
|
42
42
|
VALID_DEPENDENCY_NODE_KINDS: ["value", "type"],
|
|
43
43
|
DEFAULT_DEPENDENCY_NODES: {
|
|
44
|
+
require: [
|
|
45
|
+
// Note: detects "require('source')"
|
|
46
|
+
{
|
|
47
|
+
selector: "CallExpression[callee.name=require] > Literal",
|
|
48
|
+
kind: "value",
|
|
49
|
+
},
|
|
50
|
+
],
|
|
44
51
|
import: [
|
|
45
52
|
// Note: detects "import x from 'source'"
|
|
46
53
|
{ selector: "ImportDeclaration:not([importKind=type]) > Literal", kind: "value" },
|
|
@@ -140,16 +140,20 @@ function validateElements(elements) {
|
|
|
140
140
|
}
|
|
141
141
|
if (element.mode && !VALID_MODES.includes(element.mode)) {
|
|
142
142
|
warnOnce(
|
|
143
|
-
`Invalid mode property
|
|
143
|
+
`Invalid mode property of type ${
|
|
144
|
+
element.type
|
|
145
|
+
} in '${ELEMENTS}' setting. Should be one of ${VALID_MODES.join(
|
|
144
146
|
",",
|
|
145
147
|
)}. Default value "${VALID_MODES[0]}" will be used instead`,
|
|
146
148
|
);
|
|
147
149
|
}
|
|
148
150
|
if (!element.pattern || !(isString(element.pattern) || isArray(element.pattern))) {
|
|
149
|
-
warnOnce(
|
|
151
|
+
warnOnce(
|
|
152
|
+
`Please provide a valid pattern to type ${element.type} in '${ELEMENTS}' setting`,
|
|
153
|
+
);
|
|
150
154
|
}
|
|
151
155
|
if (element.capture && !isArray(element.capture)) {
|
|
152
|
-
warnOnce(`Invalid capture property in '${ELEMENTS}' setting`);
|
|
156
|
+
warnOnce(`Invalid capture property of type ${element.type} in '${ELEMENTS}' setting`);
|
|
153
157
|
}
|
|
154
158
|
});
|
|
155
159
|
}
|