-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new development flow thjs-123
- Loading branch information
1 parent
48d91f6
commit 696b712
Showing
5 changed files
with
98 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,22 @@ | ||
import { type SyncRule, type UserConfig } from '@commitlint/types'; | ||
import { RuleConfigSeverity, type UserConfig } from '@commitlint/types'; | ||
|
||
import { ProjectPrefix } from './project.config.js'; | ||
|
||
const COMMIT_MODIFIERS = ['+', '*', '-']; | ||
const COMMIT_MESSAGE_REGEXP = new RegExp( | ||
`^(((${ProjectPrefix.APP})-[0-9]{1,6})|(${ProjectPrefix.ENVIRONMENTS.join( | ||
'|' | ||
)})): ([${COMMIT_MODIFIERS.join(',')}]) (.*\\S)$` | ||
); | ||
const COMMIT_MESSAGE_MATCH_RULE_MESSAGE = `commit message doesn't match format requirements | ||
Commit message must have one of the following formats: | ||
- <project-prefix>-<issue-number>: <modifier> <description> | ||
- <environment>: <modifier> <description> | ||
Where: | ||
- <project-prefix>: ${ProjectPrefix.APP} | ||
- <modifier>: ${COMMIT_MODIFIERS.join(', ')} | ||
- <environment>: ${ProjectPrefix.ENVIRONMENTS.join(', ')} | ||
Examples: | ||
- ${ProjectPrefix.APP}-5: + ui/ux lecture | ||
- ${ProjectPrefix.APP}-12: * docker homework | ||
- production: - comments in ui/ux homework`; | ||
|
||
const configuration: UserConfig = { | ||
defaultIgnores: true, | ||
const config: UserConfig = { | ||
extends: ['@commitlint/config-conventional'], | ||
parserPreset: { | ||
parserOpts: { | ||
headerCorrespondence: ['prefix', 'modifier', 'description'], | ||
headerPattern: COMMIT_MESSAGE_REGEXP | ||
issuePrefixes: ProjectPrefix.ISSUE_PREFIXES.map(prefix => `${prefix}-`) | ||
} | ||
}, | ||
plugins: [ | ||
{ | ||
rules: { | ||
'commit-message-match': (({ header }) => { | ||
if (!COMMIT_MESSAGE_REGEXP.test(header as string)) { | ||
return [false, COMMIT_MESSAGE_MATCH_RULE_MESSAGE]; | ||
} | ||
|
||
return [true]; | ||
}) as SyncRule | ||
} | ||
} | ||
], | ||
rules: { | ||
'commit-message-match': [2, 'always'] | ||
'references-empty': [RuleConfigSeverity.Error, 'never'], | ||
'scope-enum': [ | ||
RuleConfigSeverity.Error, | ||
'always', | ||
[...ProjectPrefix.SCOPES.APPS, ...ProjectPrefix.SCOPES.PACKAGES] | ||
] | ||
} | ||
}; | ||
|
||
export default configuration; | ||
export default config; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,23 @@ | ||
const ProjectPrefix = { | ||
APP: 'thjs', | ||
ENVIRONMENTS: ['development', 'production'] | ||
CHANGE_TYPES: [ | ||
'build', | ||
'chore', | ||
'ci', | ||
'docs', | ||
'feat', | ||
'fix', | ||
'perf', | ||
'refactor', | ||
'revert', | ||
'style', | ||
'test' | ||
], | ||
ENVIRONMENTS: ['production', 'development'], | ||
ISSUE_PREFIXES: ['thjs'], | ||
SCOPES: { | ||
APPS: ['frontend', 'backend'], | ||
PACKAGES: ['shared'] | ||
} | ||
} as const; | ||
|
||
export { ProjectPrefix }; |