eslint-plugin-stratified-design 0.5.0 → 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.
|
@@ -79,6 +79,7 @@ const reportHasProperLevelNumber = (context, options, rootDir, filePath) => {
|
|
|
79
79
|
*/
|
|
80
80
|
return (node, modulePath) => {
|
|
81
81
|
if (!options.useLevelNumber) return;
|
|
82
|
+
if (isNodeModule(rootDir)(modulePath)) return;
|
|
82
83
|
|
|
83
84
|
const report = (messageId) =>
|
|
84
85
|
reportError(context, rootDir, filePath)(node, messageId, modulePath);
|
|
@@ -184,12 +185,15 @@ const reportHasProperLevel = (
|
|
|
184
185
|
|
|
185
186
|
const isNodeModulePath = isNodeModule(rootDir)(modulePath);
|
|
186
187
|
|
|
188
|
+
const moduleLevel = findLevel(modulePath);
|
|
189
|
+
|
|
187
190
|
if (fileLevel === null) {
|
|
188
|
-
if (!isNodeModulePath)
|
|
191
|
+
if (moduleLevel !== null || !isNodeModulePath) {
|
|
192
|
+
report("not-registered:file");
|
|
193
|
+
}
|
|
189
194
|
return FINISHED;
|
|
190
195
|
}
|
|
191
196
|
|
|
192
|
-
const moduleLevel = findLevel(modulePath);
|
|
193
197
|
if (moduleLevel === null) {
|
|
194
198
|
if (!isNodeModulePath) report("not-registered:module");
|
|
195
199
|
return FINISHED;
|
package/package.json
CHANGED
|
@@ -58,7 +58,7 @@ ruleTester.run("lower-level-imports", rule, {
|
|
|
58
58
|
options: [{ structure, root: "./src", aliases: { "@/": "./src/" } }],
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
|
-
code: "import { func } from 'node-module'",
|
|
61
|
+
code: "import { func } from 'other-node-module'",
|
|
62
62
|
filename: "./src/otherLayerA.js",
|
|
63
63
|
options: [{ structure, root: "./src" }],
|
|
64
64
|
},
|
|
@@ -170,6 +170,23 @@ ruleTester.run("lower-level-imports", rule, {
|
|
|
170
170
|
},
|
|
171
171
|
],
|
|
172
172
|
},
|
|
173
|
+
{
|
|
174
|
+
code: "import { func } from 'other-node-module'",
|
|
175
|
+
filename: "./src/1 otherLayerA.js",
|
|
176
|
+
options: [{ structure, root: "./src", useLevelNumber: true }],
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
code: "import { func } from 'node-module'",
|
|
180
|
+
filename: "./src/layer2/subLayer1/1 layer.js",
|
|
181
|
+
options: [
|
|
182
|
+
{
|
|
183
|
+
structure,
|
|
184
|
+
root: "./src",
|
|
185
|
+
aliases: { "@/": "./src/" },
|
|
186
|
+
useLevelNumber: true,
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
},
|
|
173
190
|
],
|
|
174
191
|
invalid: [
|
|
175
192
|
{
|
|
@@ -310,5 +327,16 @@ ruleTester.run("lower-level-imports", rule, {
|
|
|
310
327
|
},
|
|
311
328
|
],
|
|
312
329
|
},
|
|
330
|
+
{
|
|
331
|
+
code: "import { func } from 'node-module'",
|
|
332
|
+
filename: "./src/layer3/subLayer1/1 layer.js",
|
|
333
|
+
options: [{ structure, root: "./src", useLevelNumber: true }],
|
|
334
|
+
errors: [
|
|
335
|
+
{
|
|
336
|
+
messageId: "not-lower-level",
|
|
337
|
+
data: { module: "node-module", file: "./layer3/subLayer1/1 layer" },
|
|
338
|
+
},
|
|
339
|
+
],
|
|
340
|
+
},
|
|
313
341
|
],
|
|
314
342
|
});
|