@@ -17,6 +17,14 @@ const docsUrl = require('../util/docsUrl');
17
17
const report = require ( '../util/report' ) ;
18
18
const getText = require ( '../util/eslint' ) . getText ;
19
19
20
+ /** @typedef {import('eslint').Rule.RuleModule } RuleModule */
21
+
22
+ /** @typedef {import('../../types/rules/jsx-no-literals').Config } Config */
23
+ /** @typedef {import('../../types/rules/jsx-no-literals').RawConfig } RawConfig */
24
+ /** @typedef {import('../../types/rules/jsx-no-literals').ResolvedConfig } ResolvedConfig */
25
+ /** @typedef {import('../../types/rules/jsx-no-literals').OverrideConfig } OverrideConfig */
26
+ /** @typedef {import('../../types/rules/jsx-no-literals').ElementConfig } ElementConfig */
27
+
20
28
// ------------------------------------------------------------------------------
21
29
// Rule Definition
22
30
// ------------------------------------------------------------------------------
@@ -45,7 +53,7 @@ const messages = {
45
53
literalNotInJSXExpressionInElement : 'Missing JSX expression container around literal string: "{{text}}" in {{element}}' ,
46
54
} ;
47
55
48
- /** @type {Exclude<import('eslint').Rule. RuleModule['meta']['schema'], unknown[]>['properties'] } */
56
+ /** @type {Exclude<RuleModule['meta']['schema'], unknown[] | false >['properties'] } */
49
57
const commonPropertiesSchema = {
50
58
noStrings : {
51
59
type : 'boolean' ,
@@ -65,52 +73,7 @@ const commonPropertiesSchema = {
65
73
} ,
66
74
} ;
67
75
68
- /**
69
- * @typedef RawElementConfigProperties
70
- * @property {boolean } [noStrings]
71
- * @property {string[] } [allowedStrings]
72
- * @property {boolean } [ignoreProps]
73
- * @property {boolean } [noAttributeStrings]
74
- *
75
- * @typedef RawOverrideConfigProperties
76
- * @property {boolean } [allowElement]
77
- * @property {boolean } [applyToNestedElements=true]
78
- *
79
- * @typedef {RawElementConfigProperties } RawElementConfig
80
- * @typedef {RawElementConfigProperties & RawElementConfigProperties } RawOverrideConfig
81
- *
82
- * @typedef RawElementOverrides
83
- * @property {Record<string, RawOverrideConfig> } [elementOverrides]
84
- *
85
- * @typedef {RawElementConfig & RawElementOverrides } RawConfig
86
- *
87
- * ----------------------------------------------------------------------
88
- *
89
- * @typedef ElementConfigType
90
- * @property {'element' } type
91
- *
92
- * @typedef ElementConfigProperties
93
- * @property {boolean } noStrings
94
- * @property {Set<string> } allowedStrings
95
- * @property {boolean } ignoreProps
96
- * @property {boolean } noAttributeStrings
97
- *
98
- * @typedef OverrideConfigProperties
99
- * @property {'override' } type
100
- * @property {string } name
101
- * @property {boolean } allowElement
102
- * @property {boolean } applyToNestedElements
103
- *
104
- * @typedef {ElementConfigType & ElementConfigProperties } ElementConfig
105
- * @typedef {OverrideConfigProperties & ElementConfigProperties } OverrideConfig
106
- *
107
- * @typedef ElementOverrides
108
- * @property {Record<string, OverrideConfig> } elementOverrides
109
- *
110
- * @typedef {ElementConfig & ElementOverrides } Config
111
- * @typedef {Config | OverrideConfig } ResolvedConfig
112
- */
113
-
76
+ // eslint-disable-next-line valid-jsdoc
114
77
/**
115
78
* Normalizes the element portion of the config
116
79
* @param {RawConfig } config
@@ -128,6 +91,7 @@ function normalizeElementConfig(config) {
128
91
} ;
129
92
}
130
93
94
+ // eslint-disable-next-line valid-jsdoc
131
95
/**
132
96
* Normalizes the config and applies default values to all config options
133
97
* @param {RawConfig } config
@@ -182,8 +146,9 @@ const elementOverrides = {
182
146
} ,
183
147
} ;
184
148
149
+ /** @type {RuleModule } */
185
150
module . exports = {
186
- meta : /** @type {import('eslint').Rule. RuleModule[" meta" ] } */ ( {
151
+ meta : /** @type {RuleModule[' meta' ] } */ ( {
187
152
docs : {
188
153
description : 'Disallow usage of string literals in JSX' ,
189
154
category : 'Stylistic Issues' ,
@@ -339,6 +304,7 @@ module.exports = {
339
304
return some ( iterFrom ( [ ancestors . parent , ancestors . grandParent ] ) , ( parent ) => jsxElementTypes . has ( parent . type ) ) ;
340
305
}
341
306
307
+ // eslint-disable-next-line valid-jsdoc
342
308
/**
343
309
* Determines whether a given node's value and its immediate parent are
344
310
* viable text nodes that can/should be reported on
@@ -370,6 +336,7 @@ module.exports = {
370
336
return isStandardJSXNode && parent . type !== 'JSXExpressionContainer' ;
371
337
}
372
338
339
+ // eslint-disable-next-line valid-jsdoc
373
340
/**
374
341
* Gets an override config for a given node. For any given node, we also
375
342
* need to traverse the ancestor tree to determine if an ancestor's config
@@ -408,6 +375,7 @@ module.exports = {
408
375
}
409
376
}
410
377
378
+ // eslint-disable-next-line valid-jsdoc
411
379
/**
412
380
* @param {ResolvedConfig } resolvedConfig
413
381
* @returns {boolean }
@@ -416,6 +384,7 @@ module.exports = {
416
384
return resolvedConfig . type === 'override' && 'allowElement' in resolvedConfig && ! ! resolvedConfig . allowElement ;
417
385
}
418
386
387
+ // eslint-disable-next-line valid-jsdoc
419
388
/**
420
389
* @param {boolean } ancestorIsJSXElement
421
390
* @param {ResolvedConfig } resolvedConfig
@@ -433,6 +402,7 @@ module.exports = {
433
402
return resolvedConfig . type === 'override' ? 'literalNotInJSXExpressionInElement' : 'literalNotInJSXExpression' ;
434
403
}
435
404
405
+ // eslint-disable-next-line valid-jsdoc
436
406
/**
437
407
* @param {ASTNode } node
438
408
* @param {string } messageId
0 commit comments