File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * @file Unit Tests - scopes
3+ * @module commitlint-config/utils/tests/unit/scopes
4+ */
5+
6+ import { Scope } from '#src/enums'
7+ import testSubject from '../scopes'
8+
9+ describe ( 'unit:utils/scopes' , ( ) => {
10+ it ( 'should return array containing valid commit scopes' , ( ) => {
11+ // Arrange
12+ const extras : string [ ] = [ 'build' , 'bundle' , 'transpile' ]
13+
14+ // Act + Expect
15+ expect ( testSubject ( extras ) ) . to . include . members ( [
16+ ...new Set < string > ( [ ...Object . values ( Scope ) , ...extras ] )
17+ ] )
18+ } )
19+ } )
Original file line number Diff line number Diff line change 55
66export { default as max } from './max'
77export { default as min } from './min'
8+ export { default as scopes } from './scopes'
Original file line number Diff line number Diff line change 1+ /**
2+ * @file Utilities - scopes
3+ * @module commitlint-config/utils/scopes
4+ */
5+
6+ import { Scope } from '#src/enums'
7+ import type { LiteralUnion } from '@flex-development/tutils'
8+
9+ /**
10+ * Returns an array of valid commit scopes.
11+ *
12+ * @param {(Set<string> | string[])? } [extras=[]] - Additional commit scopes
13+ * @return {LiteralUnion<Scope, string>[] } Commit scopes array
14+ */
15+ const scopes = (
16+ extras : Set < string > | string [ ] = [ ]
17+ ) : LiteralUnion < Scope , string > [ ] => {
18+ return [ ...new Set ( [ ...Object . values ( Scope ) , ...extras ] ) ] . sort ( ( s1 , s2 ) => {
19+ return s1 . localeCompare ( s2 )
20+ } )
21+ }
22+
23+ export default scopes
You can’t perform that action at this time.
0 commit comments