Skip to content

Commit

Permalink
feat: rename encapsulationPatternForBarrelLess to `encapsulationPat…
Browse files Browse the repository at this point in the history
…tern`
  • Loading branch information
rainerhahnekamp committed Oct 28, 2024
1 parent ad987cb commit dc3edb5
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function hasEncapsulationViolations(
accessesExposedFileForBarrelLessModules(
importedFileInfo,
config.enableBarrelLess,
config.encapsulationPatternForBarrelLess,
config.encapsulationPattern,
)
) {
// 👍 all good
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('barrel-less', () => {

it('should be able to change the name of internals', () => {
assertProject({
encapsulationPatternForBarrelLess: 'private',
encapsulationPattern: 'private',
})
.withCustomerRoute({
feature: {
Expand All @@ -171,7 +171,7 @@ describe('barrel-less', () => {
});

it('should always prioritize the barrel file', () => {
assertProject({ showWarningOnBarrelCollision: false })
assertProject()
.withCustomerRoute({
feature: {
'customer.component.ts': ['../data'],
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('barrel-less', () => {
});

it.skip('should support wildcards', () => {
assertProject({ encapsulationPatternForBarrelLess: '**/internal' })
assertProject({ encapsulationPattern: '**/internal' })
.withCustomerRoute({
feature: {
'customer.component.ts': [],
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/config/default-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const defaultConfig: Configuration = {
depRules: {},
excludeRoot: false,
enableBarrelLess: false,
encapsulationPatternForBarrelLess: 'internal',
encapsulationPattern: 'internal',
log: false,
entryFile: '',
isConfigFileMissing: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/config/parse-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export const parseConfig = (configFile: FsPath): Configuration => {
}

if (
userSheriffConfig.encapsulationPatternForBarrelLess !== undefined &&
userSheriffConfig.encapsulationPattern !== undefined &&
userSheriffConfig.encapsulatedFolderNameForBarrelLess !== undefined
) {
throw new CollidingEncapsulationSettings();
}

if (userSheriffConfig.encapsulatedFolderNameForBarrelLess) {
userSheriffConfig.encapsulationPatternForBarrelLess =
userSheriffConfig.encapsulationPattern =
userSheriffConfig.encapsulatedFolderNameForBarrelLess;
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/lib/config/tests/parse-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('parse Config', () => {
'depRules',
'excludeRoot',
'enableBarrelLess',
'encapsulationPatternForBarrelLess',
'encapsulationPattern',
'log',
'entryFile',
'isConfigFileMissing',
Expand Down Expand Up @@ -72,7 +72,7 @@ export const config: SheriffConfig = {
modules: {},
depRules: { noTag: 'noTag' },
enableBarrelLess: false,
encapsulationPatternForBarrelLess: 'internal',
encapsulationPattern: 'internal',
excludeRoot: false,
log: false,
isConfigFileMissing: false,
Expand Down Expand Up @@ -154,7 +154,7 @@ export const config: SheriffConfig = {

expect(parseConfig(
toFsPath(getFs().cwd() + '/sheriff.config.ts')
).encapsulationPatternForBarrelLess).toBe('_private')
).encapsulationPattern).toBe('_private')
})

it('should throw if both encapsulatedFolderNameForBarrelLess and encapsulationPatternForBarrelLess exist', () => {
Expand All @@ -169,7 +169,7 @@ export const config: SheriffConfig = {
'noTag': 'noTag',
},
encapsulatedFolderNameForBarrelLess: 'internal',
encapsulationPatternForBarrelLess: 'internal'
encapsulationPattern: 'internal'
};
`,
);
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/config/user-sheriff-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export interface UserSheriffConfig {
* which are not available outside the module.
* By default, it is set to `internal`.
*
* @deprecated use {@link encapsulationPatternForBarrelLess} instead
* @deprecated use {@link encapsulationPattern} instead
*/
encapsulatedFolderNameForBarrelLess?: string;

Expand All @@ -200,7 +200,7 @@ export interface UserSheriffConfig {
* This is a more powerful alternative to
* {@link encapsulatedFolderNameForBarrelLess}.
*/
encapsulationPatternForBarrelLess?: string
encapsulationPattern?: string

/**
* @deprecated no warning is shown.
Expand Down

0 comments on commit dc3edb5

Please sign in to comment.