eslint-plugin-stratified-design 0.12.2 → 0.12.3

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.
@@ -140,7 +140,7 @@ module.exports = {
140
140
  return {
141
141
  Program(node) {
142
142
  node.body.forEach((token) => {
143
- const declaration = token.type === 'ExportNamedDeclaration' || token.type === 'ExportDefaultDeclaration' ? token.declaration : token
143
+ const declaration = (token.type === 'ExportNamedDeclaration' || token.type === 'ExportDefaultDeclaration') && Boolean(token.declaration) ? token.declaration : token
144
144
  const isFuncDeclaration = declaration.type === "FunctionDeclaration";
145
145
  const isVarDeclaration =
146
146
  declaration.type === "VariableDeclaration" &&
@@ -152,7 +152,7 @@ module.exports = {
152
152
  ].includes(declaration.declarations[0].init.type);
153
153
 
154
154
  if (isFuncDeclaration || isVarDeclaration) {
155
- const level = deriveLevel(sourceCode, declaration);
155
+ const level = deriveLevel(sourceCode, token);
156
156
  const name = isFuncDeclaration
157
157
  ? declaration.id.name
158
158
  : declaration.declarations[0].id.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-stratified-design",
3
- "version": "0.12.2",
3
+ "version": "0.12.3",
4
4
  "description": "ESlint rules for stratified design",
5
5
  "keywords": [
6
6
  "eslint",
@@ -50,30 +50,60 @@ ruleTester.run("no-same-level-funcs", rule, {
50
50
  filename: "./src/foo.js",
51
51
  options: [{ include: ["src/**/*.*"], exclude: ["src/foo.js"] }],
52
52
  },
53
+
53
54
  {
54
55
  code: "// @level 2\nfunction func2(){};\n// @level 1\nfunction func1(){ func2(); }",
55
56
  filename: "./src/foo.js",
56
57
  },
58
+ {
59
+ code: "// @level 2\nexport function func2(){};\n// @level 1\nfunction func1(){ func2(); }",
60
+ filename: "./src/foo.js",
61
+ },
62
+
57
63
  {
58
64
  code: "// @level 2\nconst func2 = () => {};\n// @level 1\nfunction func1(){ func2(); }",
59
65
  filename: "./src/foo.js",
60
66
  },
67
+ {
68
+ code: "// @level 2\nexport const func2 = () => {};\n// @level 1\nfunction func1(){ func2(); }",
69
+ filename: "./src/foo.js",
70
+ },
71
+
61
72
  {
62
73
  code: "// @level 2\nconst func2 = () => {};\n// @level 1\nconst func1 = () => func2();",
63
74
  filename: "./src/foo.js",
64
75
  },
76
+ {
77
+ code: "// @level 2\nexport const func2 = () => {};\n// @level 1\nconst func1 = () => func2();",
78
+ filename: "./src/foo.js",
79
+ },
80
+
65
81
  {
66
82
  code: "/*@level 2*/\nconst func2 = () => {};\n/*@level 1*/\nconst func1 = () => func2();",
67
83
  filename: "./src/foo.js",
68
84
  },
85
+ {
86
+ code: "/*@level 2*/\nexport const func2 = () => {};\n/*@level 1*/\nconst func1 = () => func2();",
87
+ filename: "./src/foo.js",
88
+ },
89
+
69
90
  {
70
91
  code: "// @level 2 something\nconst func2 = () => {};\n// @level 1 something\nconst func1 = () => func2();",
71
92
  filename: "./src/foo.js",
72
93
  },
94
+ {
95
+ code: "// @level 2 something\nexport const func2 = () => {};\n// @level 1 something\nconst func1 = () => func2();",
96
+ filename: "./src/foo.js",
97
+ },
98
+
73
99
  {
74
100
  code: "/*\n@level 2\nsomething\n*/\nconst func2 = () => {};\n/*something\n@level 1\n*/\nconst func1 = () => func2();",
75
101
  filename: "./src/foo.js",
76
102
  },
103
+ {
104
+ code: "/*\n@level 2\nsomething\n*/\nexport const func2 = () => {};\n/*something\n@level 1\n*/\nconst func1 = () => func2();",
105
+ filename: "./src/foo.js",
106
+ },
77
107
  ],
78
108
  invalid: [
79
109
  {
@@ -192,11 +222,18 @@ ruleTester.run("no-same-level-funcs", rule, {
192
222
  filename: "./src/foo.js",
193
223
  errors: [{ messageId: "no-same-level-funcs", data: { func: "func1" } }],
194
224
  },
225
+
195
226
  {
196
227
  code: "// @level 2\nfunction func2(){};\nfunction func1(){ func2(); }",
197
228
  filename: "./src/foo.js",
198
229
  errors: [{ messageId: "no-same-level-funcs", data: { func: "func2" } }],
199
230
  },
231
+ {
232
+ code: "// @level 2\nexport function func2(){};\nfunction func1(){ func2(); }",
233
+ filename: "./src/foo.js",
234
+ errors: [{ messageId: "no-same-level-funcs", data: { func: "func2" } }],
235
+ },
236
+
200
237
  {
201
238
  code: "function func2(){};\n// @level 1\nfunction func1(){ func2(); }",
202
239
  filename: "./src/foo.js",