@@ -779,8 +779,8 @@ disabling of ESLint directives which are not needed by the resolved rules
779
779
will be reported as with the ESLint ` --report-unused-disable-directives `
780
780
command.
781
781
782
- <a name =" eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples -and-baseconfig " ></a >
783
- #### Options for Determining ESLint Rule Applicability (<code >allowInlineConfig</code >, <code >noDefaultExampleRules</code >, <code >matchingFileName</code >, <code >configFile</code >, <code >eslintrcForExamples </code >, and <code >baseConfig</code >)
782
+ <a name =" eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc -and-baseconfig " ></a >
783
+ #### Options for Determining ESLint Rule Applicability (<code >allowInlineConfig</code >, <code >noDefaultExampleRules</code >, <code >matchingFileName</code >, <code >configFile</code >, <code >checkEslintrc </code >, and <code >baseConfig</code >)
784
784
785
785
The following options determine which individual ESLint rules will be
786
786
applied to the JavaScript found within the ` @example ` tags (as determined
@@ -793,6 +793,7 @@ decreasing precedence:
793
793
* ` noDefaultExampleRules ` - Setting to ` true ` will disable the
794
794
default rules which are expected to be troublesome for most documentation
795
795
use. See the section below for the specific default rules.
796
+ * ` configFile ` - A config file. Corresponds to ESLint's [ ` -c ` ] ( https://eslint.org/docs/user-guide/command-line-interface#-c---config ) .
796
797
* ` matchingFileName ` - Option for a file name (even non-existent) to trigger
797
798
specific rules defined in one's config; usable with ESLint ` .eslintrc.* `
798
799
` overrides ` -> ` files ` globs, to apply a desired subset of rules with
@@ -801,16 +802,26 @@ decreasing precedence:
801
802
with JavaScript Markdown lintable by
802
803
[ other plugins] ( https://github.com/eslint/eslint-plugin-markdown ) , e.g.,
803
804
if one sets ` matchingFileName ` to ` dummy.md ` so that ` @example ` rules will
804
- follow one's Markdown rules). Note that this option may come at somewhat
805
- of a performance penalty as the file's existence is checked by eslint.
806
- * ` configFile ` - A config file. Corresponds to ESLint's [ ` -c ` ] ( https://eslint.org/docs/user-guide/command-line-interface#-c---config ) .
807
- * ` eslintrcForExamples ` - Defaults to ` true ` in adding rules
805
+ follow one's Markdown rules).
806
+ * ` checkEslintrc ` - Defaults to ` true ` in adding rules
808
807
based on an ` .eslintrc.* ` file. Setting to ` false ` corresponds to
809
808
ESLint's [ ` --no-eslintrc ` ] ( https://eslint.org/docs/user-guide/command-line-interface#--no-eslintrc ) .
809
+ If ` matchingFileName ` is set, this will automatically be ` true ` and
810
+ will use the config corresponding to that file. If ` matchingFileName ` is
811
+ not set and this value is set to ` false ` , the ` .eslintrc.* ` configs will
812
+ not be checked. If ` matchingFileName ` is not set, and this is unset or
813
+ set to ` true ` , the ` .eslintrc.* ` configs will be checked as though the file
814
+ name were the same as the file containing the example, with any file
815
+ extension changed to ".md" (and if there is no file extension, "dummy.md"
816
+ will be used). This allows convenient sharing of similar rules with often
817
+ also context-free Markdown as well as use of ` overrides ` as described under
818
+ ` matchingFileName ` . Note that this option (whether set by ` matchingFileName `
819
+ or set manually to ` true ` ) may come at somewhat of a performance penalty
820
+ as the file's existence is checked by eslint.
810
821
* ` baseConfig ` - Set to an object of rules with the same schema
811
822
as ` .eslintrc.* ` for defaults.
812
823
813
- <a name =" eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples -and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true " ></a >
824
+ <a name =" eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-checkeslintrc -and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true " ></a >
814
825
##### Rules Disabled by Default Unless <code >noDefaultExampleRules</code > is Set to <code >true</code >
815
826
816
827
* ` eol-last ` - Insisting that a newline "always" be at the end is less likely
@@ -848,7 +859,7 @@ The following patterns are considered problems:
848
859
function quux () {
849
860
850
861
}
851
- // Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"eslintrcForExamples ":false}]
862
+ // Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc ":false}]
852
863
// Message: @example error (no-alert): Unexpected alert.
853
864
854
865
/**
@@ -857,7 +868,7 @@ function quux () {
857
868
class quux {
858
869
859
870
}
860
- // Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"eslintrcForExamples ":false}]
871
+ // Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"checkEslintrc ":false}]
861
872
// Message: @example error (no-alert): Unexpected alert.
862
873
863
874
/**
@@ -868,7 +879,7 @@ class quux {
868
879
function quux () {
869
880
870
881
}
871
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
882
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
872
883
// Message: @example error (semi): Extra semicolon.
873
884
874
885
/**
@@ -879,7 +890,7 @@ function quux () {
879
890
function quux () {
880
891
881
892
}
882
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
893
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
883
894
// Message: @example error (semi): Extra semicolon.
884
895
885
896
/**
@@ -889,7 +900,7 @@ function quux () {
889
900
var quux = {
890
901
891
902
};
892
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
903
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
893
904
// Message: @example error (semi): Extra semicolon.
894
905
895
906
/**
@@ -899,7 +910,7 @@ var quux = {
899
910
function quux () {
900
911
901
912
}
902
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}]
913
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}]
903
914
// Message: @example error (semi): Extra semicolon.
904
915
905
916
/**
@@ -914,7 +925,7 @@ function quux () {
914
925
function quux2 () {
915
926
916
927
}
917
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s*$"}]
928
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s*$"}]
918
929
// Message: @example error (semi): Extra semicolon.
919
930
920
931
/**
@@ -924,7 +935,7 @@ function quux2 () {
924
935
function quux () {
925
936
926
937
}
927
- // Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":true}]
938
+ // Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":true}]
928
939
// Message: @example error (no-undef): 'quux' is not defined.
929
940
930
941
/**
@@ -937,7 +948,7 @@ function quux () {
937
948
function quux () {
938
949
939
950
}
940
- // Options: [{"captionRequired":true,"eslintrcForExamples ":false}]
951
+ // Options: [{"captionRequired":true,"checkEslintrc ":false}]
941
952
// Message: Caption is expected for examples.
942
953
943
954
/**
@@ -946,22 +957,22 @@ function quux () {
946
957
function quux () {
947
958
948
959
}
949
- // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
960
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
950
961
// Message: @example error (indent): Expected indentation of 0 spaces but found 1.
951
962
952
963
/**
953
964
* @example test () // eslint-disable-line semi
954
965
*/
955
966
function quux () {}
956
- // Options: [{"eslintrcForExamples ":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}]
967
+ // Options: [{"checkEslintrc ":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}]
957
968
// Message: @example error: Unused eslint-disable directive (no problems were reported from 'semi').
958
969
959
970
/**
960
971
* @example
961
972
test () // eslint-disable-line semi
962
973
*/
963
974
function quux () {}
964
- // Options: [{"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":true}]
975
+ // Options: [{"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc ":false,"noDefaultExampleRules":true}]
965
976
// Message: @example error (semi): Missing semicolon.
966
977
967
978
/**
@@ -1032,7 +1043,7 @@ function quux2 () {
1032
1043
function quux2 () {
1033
1044
1034
1045
}
1035
- // Options: [{"eslintrcForExamples ":false,"matchingFileName":"dummy.js"}]
1046
+ // Options: [{"checkEslintrc ":false,"matchingFileName":"dummy.js"}]
1036
1047
// Message: @example error: Parsing error: The keyword 'const' is reserved
1037
1048
1038
1049
/**
@@ -1043,7 +1054,7 @@ function quux2 () {
1043
1054
function quux () {
1044
1055
1045
1056
}
1046
- // Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"// begin[\\s\\S]*// end","noDefaultExampleRules":true}]
1057
+ // Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc ":false,"exampleCodeRegex":"// begin[\\s\\S]*// end","noDefaultExampleRules":true}]
1047
1058
// Message: @example warning (semi): Missing semicolon.
1048
1059
1049
1060
/**
@@ -1060,7 +1071,7 @@ function f () {
1060
1071
* @example <caption></caption>
1061
1072
* ' foo'
1062
1073
*/
1063
- // Options: [{"captionRequired":true,"eslintrcForExamples ":false}]
1074
+ // Options: [{"captionRequired":true,"checkEslintrc ":false}]
1064
1075
// Message: Caption is expected for examples.
1065
1076
1066
1077
/**
@@ -1071,7 +1082,7 @@ function f () {
1071
1082
function quux () {
1072
1083
1073
1084
}
1074
- // Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false}]
1085
+ // Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc ":false}]
1075
1086
// Message: @example error (semi): Missing semicolon.
1076
1087
1077
1088
/**
@@ -1106,7 +1117,7 @@ function quux () {
1106
1117
*
1107
1118
* ! [Screenshot](path/ to/ screenshot .jpg )
1108
1119
*/
1109
- // Options: [{"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"/^```(?:js|javascript)\\n([\\s\\S]*?)```$/gm"}]
1120
+ // Options: [{"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"checkEslintrc ":false,"exampleCodeRegex":"/^```(?:js|javascript)\\n([\\s\\S]*?)```$/gm"}]
1110
1121
// Message: @example error (semi): Missing semicolon.
1111
1122
1112
1123
/**
@@ -1121,7 +1132,7 @@ function quux () {
1121
1132
function quux () {
1122
1133
1123
1134
}
1124
- // Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"/\\/\\/ begin[\\s\\S]*?// end/g","noDefaultExampleRules":true}]
1135
+ // Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"checkEslintrc ":false,"exampleCodeRegex":"/\\/\\/ begin[\\s\\S]*?// end/g","noDefaultExampleRules":true}]
1125
1136
// Message: @example warning (semi): Missing semicolon.
1126
1137
1127
1138
/**
@@ -1131,7 +1142,7 @@ function quux () {
1131
1142
function quux () {
1132
1143
1133
1144
}
1134
- // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
1145
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
1135
1146
// Message: @example error (indent): Expected indentation of 0 spaces but found 2.
1136
1147
````
1137
1148
@@ -1146,7 +1157,7 @@ The following patterns are not considered problems:
1146
1157
function quux () {
1147
1158
1148
1159
}
1149
- // Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1160
+ // Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1150
1161
1151
1162
/**
1152
1163
* @example ` ` ` js
@@ -1156,7 +1167,7 @@ function quux () {
1156
1167
function quux () {
1157
1168
1158
1169
}
1159
- // Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"/```js([\\s\\S]*)```/"}]
1170
+ // Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc ":false,"exampleCodeRegex":"/```js([\\s\\S]*)```/"}]
1160
1171
1161
1172
/**
1162
1173
* @example
@@ -1165,7 +1176,7 @@ function quux () {
1165
1176
function quux () {
1166
1177
1167
1178
}
1168
- // Options: [{"eslintrcForExamples ":false}]
1179
+ // Options: [{"checkEslintrc ":false}]
1169
1180
1170
1181
/**
1171
1182
* @example
@@ -1174,15 +1185,15 @@ function quux () {
1174
1185
function quux () {
1175
1186
1176
1187
}
1177
- // Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
1188
+ // Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
1178
1189
1179
1190
/**
1180
1191
* @example quux ();
1181
1192
*/
1182
1193
function quux () {
1183
1194
1184
1195
}
1185
- // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
1196
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
1186
1197
1187
1198
/**
1188
1199
* @example <caption> Valid usage </caption>
@@ -1194,20 +1205,20 @@ function quux () {
1194
1205
function quux () {
1195
1206
1196
1207
}
1197
- // Options: [{"captionRequired":true,"eslintrcForExamples ":false}]
1208
+ // Options: [{"captionRequired":true,"checkEslintrc ":false}]
1198
1209
1199
1210
/**
1200
1211
* @example test () // eslint-disable-line semi
1201
1212
*/
1202
1213
function quux () {}
1203
- // Options: [{"eslintrcForExamples ":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}]
1214
+ // Options: [{"checkEslintrc ":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}]
1204
1215
1205
1216
/**
1206
1217
* @example
1207
1218
test () // eslint-disable-line semi
1208
1219
*/
1209
1220
function quux () {}
1210
- // Options: [{"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":true}]
1221
+ // Options: [{"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"checkEslintrc ":false,"noDefaultExampleRules":true}]
1211
1222
1212
1223
/**
1213
1224
* @example ` ` ` js
@@ -1217,7 +1228,7 @@ function quux () {}
1217
1228
var quux = {
1218
1229
1219
1230
};
1220
- // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1231
+ // Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"checkEslintrc ":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1221
1232
1222
1233
/**
1223
1234
* @example
@@ -1226,7 +1237,7 @@ var quux = {
1226
1237
* });
1227
1238
*/
1228
1239
function quux () {}
1229
- // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
1240
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
1230
1241
1231
1242
/**
1232
1243
* @example
@@ -1236,7 +1247,7 @@ function quux () {}
1236
1247
function quux () {
1237
1248
1238
1249
}
1239
- // Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"eslintrcForExamples ":false}]
1250
+ // Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"checkEslintrc ":false}]
1240
1251
1241
1252
/**
1242
1253
* @example const ident = 5 ;
@@ -1257,7 +1268,7 @@ function quux2 () {
1257
1268
function quux () {
1258
1269
1259
1270
}
1260
- // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples ":false,"noDefaultExampleRules":false}]
1271
+ // Options: [{"baseConfig":{"rules":{"indent":["error"]}},"checkEslintrc ":false,"noDefaultExampleRules":false}]
1261
1272
````
1262
1273
1263
1274
0 commit comments