eslint-plugin-stratified-design 0.12.0 → 0.12.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.
@@ -136,8 +136,10 @@ module.exports = {
136
136
  return [theMember, theImportSpec];
137
137
  }
138
138
 
139
+ const isModulePathMatched = match(fromCwd(context.cwd, modulePath))(importSpec.import.from)
140
+
139
141
  if (importSpec.import.member === ANY_MEMBER) {
140
- return ['Any member', importSpec]
142
+ return isModulePathMatched ? ['Any member', importSpec] : [undefined, undefined]
141
143
  }
142
144
 
143
145
  const importedSpecifiers = node.specifiers.map((specifier) => {
@@ -152,10 +154,7 @@ module.exports = {
152
154
  importedSpecifiers.some((sp) => sp === specifier)
153
155
  );
154
156
 
155
- if (
156
- member &&
157
- match(fromCwd(context.cwd, modulePath))(importSpec.import.from)
158
- ) {
157
+ if (member && isModulePathMatched) {
159
158
  if (member === DEFAULT || member === NAMESPACE) {
160
159
  const theMember = node.specifiers.find(
161
160
  ({ type }) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-stratified-design",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "ESlint rules for stratified design",
5
5
  "keywords": [
6
6
  "eslint",
@@ -131,6 +131,20 @@ ruleTester.run("no-disallowed-imports", rule, {
131
131
  },
132
132
  ],
133
133
  },
134
+ {
135
+ code: "import { foo } from 'nodeModule'",
136
+ filename: "./src/fileB.js",
137
+ options: [
138
+ {
139
+ imports: [
140
+ {
141
+ import: { member: ["*"], from: "src/fileA" },
142
+ disallow: ["src/**/*.js"],
143
+ },
144
+ ],
145
+ },
146
+ ],
147
+ },
134
148
  {
135
149
  code: "import { anyMember } from './fileA'",
136
150
  filename: "./src/fileB.js",
@@ -159,6 +173,48 @@ ruleTester.run("no-disallowed-imports", rule, {
159
173
  },
160
174
  ],
161
175
  },
176
+ {
177
+ code: "import { anyMember } from './fileA.act'",
178
+ filename: "./src/fileB.cal.js",
179
+ options: [
180
+ {
181
+ imports: [
182
+ {
183
+ import: { member: "*", from: "**/*.act" },
184
+ allow: ["src/**/*.cal.js"],
185
+ },
186
+ ],
187
+ },
188
+ ],
189
+ },
190
+ {
191
+ code: "import { anyMember } from 'fileA.cal'",
192
+ filename: "./src/fileB.act.js",
193
+ options: [
194
+ {
195
+ imports: [
196
+ {
197
+ import: { member: "*", from: "**/*.act" },
198
+ disallow: ["src/**/*.cal.js"],
199
+ },
200
+ ],
201
+ },
202
+ ],
203
+ },
204
+ {
205
+ code: "import { anyMember } from 'nodeModule'",
206
+ filename: "./src/fileB.cal.js",
207
+ options: [
208
+ {
209
+ imports: [
210
+ {
211
+ import: { member: "*", from: "**/*.act" },
212
+ disallow: ["src/**/*.cal.js"],
213
+ },
214
+ ],
215
+ },
216
+ ],
217
+ },
162
218
  ],
163
219
  invalid: [
164
220
  {
@@ -240,20 +296,20 @@ ruleTester.run("no-disallowed-imports", rule, {
240
296
  ],
241
297
  },
242
298
  {
243
- code: "import { anyMember } from './fileA'",
244
- filename: "./src/fileB.js",
299
+ code: "import { anyMember } from './fileA.act'",
300
+ filename: "./src/fileB.cal.js",
245
301
  options: [
246
302
  {
247
303
  imports: [
248
304
  {
249
- import: { member: "*", from: "src/fileA" },
250
- disallow: ["src/**/*.js"],
305
+ import: { member: "*", from: "**/*.act" },
306
+ disallow: ["**/*.cal.js"],
251
307
  },
252
308
  ],
253
309
  },
254
310
  ],
255
311
  errors: [
256
- { messageId: "no-disallowed-imports", data: { member: "Any member", from: "src/fileA" } },
312
+ { messageId: "no-disallowed-imports", data: { member: "Any member", from: "**/*.act" } },
257
313
  ],
258
314
  },
259
315
  ],