-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from javierbrea/release
Release v5.0.1
- Loading branch information
Showing
12 changed files
with
105 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
const { ENTRY_POINT: RULE } = require("../../../src/constants/rules"); | ||
const { SETTINGS, createRuleTester, pathResolvers } = require("../../support/helpers"); | ||
|
||
const rule = require(`../../../src/rules/${RULE}`); | ||
|
||
const { absoluteFilePath } = pathResolvers("layered"); | ||
|
||
const settings = SETTINGS.layered; | ||
|
||
// https://github.com/javierbrea/eslint-plugin-boundaries/issues/340 | ||
const options = [ | ||
{ | ||
// disallow all entry-points by default | ||
default: "disallow", | ||
rules: [ | ||
{ | ||
target: ["modules"], | ||
allow: "**", | ||
}, | ||
{ | ||
target: [ | ||
// Any element, except the same as target | ||
["modules", { elementName: "!(${from.elementName})" }], | ||
], | ||
// Any file, except index.js | ||
disallow: "!(index.js)", | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const ruleTester = createRuleTester(settings); | ||
|
||
ruleTester.run(RULE, rule, { | ||
valid: [ | ||
// helper can be imported inside the same module | ||
{ | ||
filename: absoluteFilePath("modules/module-a/components/ComponentA.js"), | ||
code: "import { someHelper } from '../helpers.js'", | ||
options, | ||
}, | ||
// helper can be imported from the pubic module API, defined in index.js | ||
{ | ||
filename: absoluteFilePath("modules/module-b/components/ComponentB.js"), | ||
code: "import { someHelper } from 'modules/module-a'", | ||
options, | ||
}, | ||
], | ||
invalid: [ | ||
// Any other file than index.js can't be imported from other module | ||
{ | ||
filename: absoluteFilePath("modules/module-b/components/ComponentB.js"), | ||
code: "import { someHelper } from 'modules/module-a/helpers.js'", | ||
options, | ||
errors: [ | ||
{ | ||
message: | ||
"The entry point 'helpers.js' is not allowed in elements of type 'modules' with elementName '!(module-a)'. Disallowed in rule 2", | ||
type: "Literal", | ||
}, | ||
], | ||
}, | ||
{ | ||
filename: absoluteFilePath("modules/module-b/components/ComponentB.js"), | ||
code: "import { someHelper } from 'modules/module-a/components/ComponentA.js'", | ||
options, | ||
errors: [ | ||
{ | ||
message: | ||
"The entry point 'components' is not allowed in elements of type 'modules' with elementName '!(module-a)'. Disallowed in rule 2", | ||
type: "Literal", | ||
}, | ||
], | ||
}, | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters