File tree Expand file tree Collapse file tree 4 files changed +58
-11
lines changed Expand file tree Collapse file tree 4 files changed +58
-11
lines changed Original file line number Diff line number Diff line change @@ -3212,7 +3212,7 @@ function quux (foo) {
3212
3212
function quux (foo ) {
3213
3213
3214
3214
}
3215
- // Message: Invalid JSDoc @license: "FOO"; expected SPDX identifier : https://spdx.org/licenses/.
3215
+ // Message: Invalid JSDoc @license: "FOO"; expected SPDX expression : https://spdx.org/licenses/.
3216
3216
3217
3217
/**
3218
3218
* @license FOO
@@ -3223,6 +3223,14 @@ function quux (foo) {
3223
3223
// Options: [{"allowedLicenses":["BAR","BAX"]}]
3224
3224
// Message: Invalid JSDoc @license: "FOO"; expected one of BAR, BAX.
3225
3225
3226
+ /**
3227
+ * @license (MIT OR GPL-2.5)
3228
+ */
3229
+ function quux (foo ) {
3230
+
3231
+ }
3232
+ // Message: Invalid JSDoc @license: "(MIT OR GPL-2.5)"; expected SPDX expression: https://spdx.org/licenses/.
3233
+
3226
3234
/**
3227
3235
* @author
3228
3236
*/
@@ -3265,6 +3273,13 @@ function quux (foo) {
3265
3273
3266
3274
}
3267
3275
3276
+ /**
3277
+ * @license (MIT OR GPL-2.0)
3278
+ */
3279
+ function quux (foo ) {
3280
+
3281
+ }
3282
+
3268
3283
/**
3269
3284
* @license FOO
3270
3285
*/
Original file line number Diff line number Diff line change 12
12
"object.entries-ponyfill" : " ^1.0.1" ,
13
13
"regextras" : " ^0.6.1" ,
14
14
"semver" : " ^6.3.0" ,
15
- "spdx-license-list " : " ^6.1 .0"
15
+ "spdx-expression-parse " : " ^3.0 .0"
16
16
},
17
17
"description" : " JSDoc linting rules for ESLint." ,
18
18
"devDependencies" : {
Original file line number Diff line number Diff line change 1
1
import semver from 'semver' ;
2
- import spdxLicenseList from 'spdx-license-list/simple ' ;
2
+ import spdxExpressionParse from 'spdx-expression-parse ' ;
3
3
import iterateJsdoc from '../iterateJsdoc' ;
4
4
5
5
export default iterateJsdoc ( ( {
@@ -56,17 +56,21 @@ export default iterateJsdoc(({
56
56
} else if ( allowedLicenses ) {
57
57
if ( allowedLicenses !== true && ! allowedLicenses . includes ( license ) ) {
58
58
report (
59
- `Invalid JSDoc @${ targetTagName } : "${ jsdocParameter . description } "; expected one of ${ allowedLicenses . join ( ', ' ) } .` ,
59
+ `Invalid JSDoc @${ targetTagName } : "${ license } "; expected one of ${ allowedLicenses . join ( ', ' ) } .` ,
60
+ null ,
61
+ jsdocParameter ,
62
+ ) ;
63
+ }
64
+ } else {
65
+ try {
66
+ spdxExpressionParse ( license ) ;
67
+ } catch ( error ) {
68
+ report (
69
+ `Invalid JSDoc @${ targetTagName } : "${ license } "; expected SPDX expression: https://spdx.org/licenses/.` ,
60
70
null ,
61
71
jsdocParameter ,
62
72
) ;
63
73
}
64
- } else if ( ! spdxLicenseList . has ( license ) ) {
65
- report (
66
- `Invalid JSDoc @${ targetTagName } : "${ jsdocParameter . description } "; expected SPDX identifier: https://spdx.org/licenses/.` ,
67
- null ,
68
- jsdocParameter ,
69
- ) ;
70
74
}
71
75
} ) ;
72
76
@@ -114,6 +118,9 @@ export default iterateJsdoc(({
114
118
} ,
115
119
] ,
116
120
} ,
121
+ licensePattern : {
122
+ type : 'string' ,
123
+ } ,
117
124
} ,
118
125
type : 'object' ,
119
126
} ,
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ export default {
92
92
errors : [
93
93
{
94
94
line : 3 ,
95
- message : 'Invalid JSDoc @license: "FOO"; expected SPDX identifier : https://spdx.org/licenses/.' ,
95
+ message : 'Invalid JSDoc @license: "FOO"; expected SPDX expression : https://spdx.org/licenses/.' ,
96
96
} ,
97
97
] ,
98
98
} ,
@@ -117,6 +117,21 @@ export default {
117
117
} ,
118
118
] ,
119
119
} ,
120
+ {
121
+ code : `
122
+ /**
123
+ * @license (MIT OR GPL-2.5)
124
+ */
125
+ function quux (foo) {
126
+
127
+ }
128
+ ` ,
129
+ errors : [
130
+ {
131
+ message : 'Invalid JSDoc @license: "(MIT OR GPL-2.5)"; expected SPDX expression: https://spdx.org/licenses/.' ,
132
+ } ,
133
+ ] ,
134
+ } ,
120
135
{
121
136
code : `
122
137
/**
@@ -186,6 +201,16 @@ export default {
186
201
}
187
202
` ,
188
203
} ,
204
+ {
205
+ code : `
206
+ /**
207
+ * @license (MIT OR GPL-2.0)
208
+ */
209
+ function quux (foo) {
210
+
211
+ }
212
+ ` ,
213
+ } ,
189
214
{
190
215
code : `
191
216
/**
You can’t perform that action at this time.
0 commit comments