diff --git a/.README/rules/check-values.md b/.README/rules/check-values.md
index eef7b9da0..ca0416b91 100644
--- a/.README/rules/check-values.md
+++ b/.README/rules/check-values.md
@@ -23,11 +23,19 @@ be checked for.
An array of allowable license values or `true` to allow any license text.
If present as an array, will be used in place of SPDX identifiers.
+##### `licensePattern`
+
+A string to be converted into a `RegExp` (with `u` flag) and whose first
+parenthetical grouping, if present, will match the portion of the license
+description to check (if no grouping is present, then the whole portion
+matched will be used). Defaults to `([^\n]*)`, i.e., the SPDX expression
+is expected before any line breaks.
+
|||
|---|---|
|Context|everywhere|
|Tags|`@version`, `@since`, `@license`, `@author`|
-|Options|`allowedAuthors`, `allowedLicenses`|
+|Options|`allowedAuthors`, `allowedLicenses`, `licensePattern`|
|Settings|`tagNamePreference`|
diff --git a/README.md b/README.md
index 99a313081..633968d8c 100644
--- a/README.md
+++ b/README.md
@@ -3156,11 +3156,20 @@ be checked for.
An array of allowable license values or `true` to allow any license text.
If present as an array, will be used in place of SPDX identifiers.
+
+##### licensePattern
+
+A string to be converted into a `RegExp` (with `u` flag) and whose first
+parenthetical grouping, if present, will match the portion of the license
+description to check (if no grouping is present, then the whole portion
+matched will be used). Defaults to `([^\n]*)`, i.e., the SPDX expression
+is expected before any line breaks.
+
|||
|---|---|
|Context|everywhere|
|Tags|`@version`, `@since`, `@license`, `@author`|
-|Options|`allowedAuthors`, `allowedLicenses`|
+|Options|`allowedAuthors`, `allowedLicenses`, `licensePattern`|
|Settings|`tagNamePreference`|
The following patterns are considered problems:
@@ -3223,6 +3232,15 @@ function quux (foo) {
// Options: [{"allowedLicenses":["BAR","BAX"]}]
// Message: Invalid JSDoc @license: "FOO"; expected one of BAR, BAX.
+/**
+ * @license MIT-7
+ * Some extra text...
+ */
+function quux (foo) {
+
+}
+// Message: Invalid JSDoc @license: "MIT-7"; expected SPDX expression: https://spdx.org/licenses/.
+
/**
* @license (MIT OR GPL-2.5)
*/
@@ -3273,6 +3291,14 @@ function quux (foo) {
}
+/**
+ * @license MIT
+ * Some extra text...
+ */
+function quux (foo) {
+
+}
+
/**
* @license (MIT OR GPL-2.0)
*/
diff --git a/src/rules/checkValues.js b/src/rules/checkValues.js
index 7bd45f98d..3067143ac 100644
--- a/src/rules/checkValues.js
+++ b/src/rules/checkValues.js
@@ -11,6 +11,7 @@ export default iterateJsdoc(({
const {
allowedLicenses = null,
allowedAuthors = null,
+ licensePattern = '([^\n]*)',
} = options;
utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => {
@@ -46,7 +47,9 @@ export default iterateJsdoc(({
}
});
utils.forEachPreferredTag('license', (jsdocParameter, targetTagName) => {
- const license = jsdocParameter.description;
+ const licenseRegex = new RegExp(licensePattern, 'g');
+ const match = jsdocParameter.description.match(licenseRegex);
+ const license = match && match[1] || match[0];
if (!license.trim()) {
report(
`Missing JSDoc @${targetTagName}.`,
diff --git a/test/rules/assertions/checkValues.js b/test/rules/assertions/checkValues.js
index e03064833..956e9f5db 100644
--- a/test/rules/assertions/checkValues.js
+++ b/test/rules/assertions/checkValues.js
@@ -117,6 +117,22 @@ export default {
},
],
},
+ {
+ code: `
+ /**
+ * @license MIT-7
+ * Some extra text...
+ */
+ function quux (foo) {
+
+ }
+ `,
+ errors: [
+ {
+ message: 'Invalid JSDoc @license: "MIT-7"; expected SPDX expression: https://spdx.org/licenses/.',
+ },
+ ],
+ },
{
code: `
/**
@@ -201,6 +217,17 @@ export default {
}
`,
},
+ {
+ code: `
+ /**
+ * @license MIT
+ * Some extra text...
+ */
+ function quux (foo) {
+
+ }
+ `,
+ },
{
code: `
/**