@@ -52,12 +52,15 @@ export class ConventionalCommit {
5252 }
5353
5454 /**
55- * Check if doc -related.
55+ * Check if a file is documentation -related.
5656 *
57- * Return true for `.rst`, README files, and anything in the docs directory.
57+ * Return true for `.rst` files, README files, and anything in the docs
58+ * directory.
5859 *
5960 * TODO: For static sites, not all `.md` files are docs but that could be
6061 * configured with a global flag. Or recognize presence of Jekyll config file.
62+ *
63+ * @returns True if the file is documentation-related, false otherwise.
6164 */
6265 isDocsRelated ( ) : boolean {
6366 if ( this . extension === ".rst" ) {
@@ -68,6 +71,14 @@ export class ConventionalCommit {
6871 return DOC_NAMES . includes ( lowerName ) || this . dirPath . startsWith ( "docs" ) ;
6972 }
7073
74+ /**
75+ * Check if a file is test-related.
76+ *
77+ * Returns true for files in test directories (at any nesting level) or
78+ * matching test-related file patterns.
79+ *
80+ * @returns True if the file is test-related, false otherwise.
81+ */
7182 isTestRelated ( ) : boolean {
7283 const dir = this . dirPath ;
7384 const name = this . name ;
@@ -102,17 +113,29 @@ export class ConventionalCommit {
102113 return false ;
103114 }
104115
116+ /**
117+ * Check if a file is CI/CD configuration-related.
118+ *
119+ * Returns true for files in CI directories or matching CI configuration file
120+ * names.
121+ *
122+ * @returns True if the file is CI/CD related, false otherwise.
123+ */
105124 isCIRelated ( ) : boolean {
106125 // Assume flat structure and don't check for nesting in subdirs of
107126 // `CI_DIRS`.
108127 return CI_DIRS . includes ( this . dirPath ) || CI_NAMES . includes ( this . name ) ;
109128 }
110129
111- // Broadly match eslint configs with any extension e.g. `.json` or `.yml`.
112- // See https://eslint.org/docs/user-guide/configuring
113- // Same for prettier configs https://prettier.io/docs/en/configuration.html
114- // And `tslint*` as JSON or YAML and `webpack*`.
115- // See https://github.com/vscode-icons/vscode-icons/blob/master/src/iconsManifest/supportedExtensions.ts
130+ /**
131+ * Check if a file is configuration-related.
132+ *
133+ * Matches ESLint, Prettier, TSLint, Webpack configs and other configuration
134+ * files with various extensions. See https://eslint.org/docs/user-guide/configuring
135+ * and https://prettier.io/docs/en/configuration.html for more details.
136+ *
137+ * @returns True if the file is configuration-related, false otherwise.
138+ */
116139 isConfigRelated ( ) : boolean {
117140 return (
118141 CONFIG_EXTENSIONS . includes ( this . extension ) ||
@@ -127,31 +150,54 @@ export class ConventionalCommit {
127150 ) ;
128151 }
129152
153+ /**
154+ * Check if a file is package management-related.
155+ *
156+ * @returns True if the file is a package manifest file, false otherwise.
157+ */
130158 isPackageRelated ( ) : boolean {
131159 return PACKAGE_NAMES . includes ( this . name ) ;
132160 }
133161
162+ /**
163+ * Check if a file is build-related.
164+ *
165+ * @returns True if the file is a build tool configuration or artifact, false
166+ * otherwise.
167+ */
134168 isBuildRelated ( ) : boolean {
135169 return (
136170 BUILD_NAMES . includes ( this . name ) ||
137171 BUILD_EXTENSIONS . includes ( this . extension )
138172 ) ;
139173 }
140174
175+ /**
176+ * Check if a file is license-related.
177+ *
178+ * @returns True if the file is a license file, false otherwise.
179+ */
141180 isLicenseRelated ( ) : boolean {
142181 return LICENSE_NAMES . includes ( this . name ) ;
143182 }
144183
184+ /**
185+ * Check if a file is chore-related (license or configuration files).
186+ *
187+ * @returns True if the file is license or configuration-related, false
188+ * otherwise.
189+ */
145190 isChoreRelated ( ) : boolean {
146191 return this . isLicenseRelated ( ) || this . isConfigRelated ( ) ;
147192 }
148193
149194 /**
150- * Return Conventional Commit type.
195+ * Determine the Conventional Commit type for this file based on its path and content .
151196 *
152- * Order of checks is important here.
197+ * Order of checks is important here: CI, package management, build, chore,
198+ * documentation, and test-related files are checked in that order.
153199 *
154- * Return the unknown/null value if no rule matches.
200+ * @returns A CONVENTIONAL_TYPE value. Returns UNKNOWN if no rule matches.
155201 */
156202 getType ( ) {
157203 if ( this . isCIRelated ( ) ) {
0 commit comments