@ntnyq/eslint-config 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +396 -118
- package/dist/index.d.cts +51 -23
- package/dist/index.d.ts +51 -23
- package/dist/index.js +396 -118
- package/package.json +10 -8
package/dist/index.js
CHANGED
|
@@ -358,14 +358,37 @@ var unCategorizedRules = {
|
|
|
358
358
|
var vue = (options = {}) => {
|
|
359
359
|
const isVue3 = options.vueVersion !== 2;
|
|
360
360
|
const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
|
|
361
|
+
const { files: FILES_VUE = [GLOB_VUE] } = options;
|
|
362
|
+
function getVueProcessor() {
|
|
363
|
+
const processorVueSFC = default3.processors[".vue"];
|
|
364
|
+
if (!sfcBlocks) return processorVueSFC;
|
|
365
|
+
return mergeProcessors2([
|
|
366
|
+
processorVueSFC,
|
|
367
|
+
default22({
|
|
368
|
+
...sfcBlocks,
|
|
369
|
+
blocks: {
|
|
370
|
+
styles: true,
|
|
371
|
+
...sfcBlocks.blocks
|
|
372
|
+
}
|
|
373
|
+
})
|
|
374
|
+
]);
|
|
375
|
+
}
|
|
361
376
|
return [
|
|
362
377
|
{
|
|
363
378
|
name: "ntnyq/vue/setup",
|
|
364
379
|
plugins: {
|
|
365
380
|
vue: default3,
|
|
366
381
|
"@typescript-eslint": plugin
|
|
367
|
-
}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: "ntnyq/vue/rules",
|
|
386
|
+
files: [
|
|
387
|
+
// File apply vue rules
|
|
388
|
+
...FILES_VUE
|
|
389
|
+
],
|
|
368
390
|
languageOptions: {
|
|
391
|
+
parser: parserVue,
|
|
369
392
|
parserOptions: {
|
|
370
393
|
sourceType: "module",
|
|
371
394
|
ecmaVersion: "latest",
|
|
@@ -375,24 +398,8 @@ var vue = (options = {}) => {
|
|
|
375
398
|
jsx: true
|
|
376
399
|
}
|
|
377
400
|
}
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
{
|
|
381
|
-
name: "ntnyq/vue/rules",
|
|
382
|
-
files: [GLOB_VUE],
|
|
383
|
-
languageOptions: {
|
|
384
|
-
parser: parserVue
|
|
385
401
|
},
|
|
386
|
-
processor:
|
|
387
|
-
default3.processors[".vue"],
|
|
388
|
-
default22({
|
|
389
|
-
...sfcBlocks,
|
|
390
|
-
blocks: {
|
|
391
|
-
styles: true,
|
|
392
|
-
...sfcBlocks.blocks
|
|
393
|
-
}
|
|
394
|
-
})
|
|
395
|
-
]),
|
|
402
|
+
processor: getVueProcessor(),
|
|
396
403
|
rules: {
|
|
397
404
|
...isVue3 ? vue3Rules : vue2Rules,
|
|
398
405
|
"vue/html-self-closing": [
|
|
@@ -894,25 +901,25 @@ var toml = (options = {}) => [
|
|
|
894
901
|
toml: default5
|
|
895
902
|
},
|
|
896
903
|
rules: {
|
|
897
|
-
"toml/comma-style": "error",
|
|
898
904
|
"toml/keys-order": "error",
|
|
905
|
+
"toml/key-spacing": "error",
|
|
906
|
+
"toml/quoted-keys": "error",
|
|
907
|
+
"toml/comma-style": "error",
|
|
908
|
+
"toml/tables-order": "error",
|
|
899
909
|
"toml/no-space-dots": "error",
|
|
900
|
-
"toml/
|
|
901
|
-
"toml/precision-of-fractional-seconds": "error",
|
|
910
|
+
"toml/spaced-comment": "error",
|
|
902
911
|
"toml/precision-of-integer": "error",
|
|
903
|
-
"toml/
|
|
904
|
-
"toml/indent": ["error", 2],
|
|
905
|
-
"toml/vue-custom-block/no-parsing-error": "error",
|
|
912
|
+
"toml/table-bracket-spacing": "error",
|
|
906
913
|
"toml/array-bracket-newline": "error",
|
|
907
|
-
"toml/array-bracket-spacing": ["error", "never"],
|
|
908
|
-
"toml/array-element-newline": ["error", "never"],
|
|
909
914
|
"toml/inline-table-curly-spacing": "error",
|
|
910
|
-
"toml/key-spacing": "error",
|
|
911
915
|
"toml/padding-line-between-pairs": "error",
|
|
912
916
|
"toml/padding-line-between-tables": "error",
|
|
913
|
-
"toml/
|
|
914
|
-
"toml/
|
|
915
|
-
"toml/
|
|
917
|
+
"toml/no-unreadable-number-separator": "error",
|
|
918
|
+
"toml/precision-of-fractional-seconds": "error",
|
|
919
|
+
"toml/vue-custom-block/no-parsing-error": "error",
|
|
920
|
+
"toml/indent": ["error", 2],
|
|
921
|
+
"toml/array-bracket-spacing": ["error", "never"],
|
|
922
|
+
"toml/array-element-newline": ["error", "never"],
|
|
916
923
|
// Overrides rules
|
|
917
924
|
...options.overrides
|
|
918
925
|
}
|
|
@@ -968,6 +975,13 @@ var antfu = (options = {}) => [
|
|
|
968
975
|
];
|
|
969
976
|
|
|
970
977
|
// src/configs/jsdoc.ts
|
|
978
|
+
var typescriptRules = {
|
|
979
|
+
"jsdoc/no-undefined-types": "off",
|
|
980
|
+
"jsdoc/require-param-type": "off",
|
|
981
|
+
"jsdoc/require-property-type": "off",
|
|
982
|
+
"jsdoc/require-returns-type": "off",
|
|
983
|
+
"jsdoc/no-types": "error"
|
|
984
|
+
};
|
|
971
985
|
var jsdoc = (options = {}) => [
|
|
972
986
|
{
|
|
973
987
|
name: "ntnyq/jsdoc",
|
|
@@ -975,23 +989,204 @@ var jsdoc = (options = {}) => [
|
|
|
975
989
|
jsdoc: default9
|
|
976
990
|
},
|
|
977
991
|
rules: {
|
|
992
|
+
// Disabled rules
|
|
993
|
+
"jsdoc/tag-lines": "off",
|
|
994
|
+
// Use `jsdoc/sort-tags`
|
|
995
|
+
"jsdoc/text-escaping": "off",
|
|
996
|
+
// No need
|
|
997
|
+
// Fixable rules
|
|
998
|
+
"jsdoc/check-alignment": "error",
|
|
999
|
+
"jsdoc/check-line-alignment": "error",
|
|
1000
|
+
"jsdoc/check-param-names": "error",
|
|
1001
|
+
"jsdoc/check-property-names": "error",
|
|
1002
|
+
"jsdoc/check-tag-names": "error",
|
|
1003
|
+
"jsdoc/check-types": "error",
|
|
1004
|
+
"jsdoc/empty-tags": "error",
|
|
1005
|
+
"jsdoc/multiline-blocks": "error",
|
|
1006
|
+
"jsdoc/no-bad-blocks": "error",
|
|
1007
|
+
"jsdoc/no-blank-block-descriptions": "error",
|
|
1008
|
+
"jsdoc/no-blank-blocks": "error",
|
|
1009
|
+
"jsdoc/no-defaults": "error",
|
|
1010
|
+
"jsdoc/no-multi-asterisks": "error",
|
|
1011
|
+
"jsdoc/require-asterisk-prefix": "error",
|
|
1012
|
+
"jsdoc/require-hyphen-before-param-description": "error",
|
|
1013
|
+
// TODO: this after investigate
|
|
1014
|
+
// 'jsdoc/sort-tags': [
|
|
1015
|
+
// 'error',
|
|
1016
|
+
// {
|
|
1017
|
+
// tagSequence: [
|
|
1018
|
+
// {
|
|
1019
|
+
// // Module/file-level
|
|
1020
|
+
// tags: ['module', 'exports', 'file', 'fileoverview', 'overview', 'import'],
|
|
1021
|
+
// },
|
|
1022
|
+
// {
|
|
1023
|
+
// // Identifying (name, type)
|
|
1024
|
+
// tags: [
|
|
1025
|
+
// 'typedef',
|
|
1026
|
+
// 'interface',
|
|
1027
|
+
// 'record',
|
|
1028
|
+
// 'template',
|
|
1029
|
+
// 'name',
|
|
1030
|
+
// 'kind',
|
|
1031
|
+
// 'type',
|
|
1032
|
+
// 'alias',
|
|
1033
|
+
// 'external',
|
|
1034
|
+
// 'host',
|
|
1035
|
+
// 'callback',
|
|
1036
|
+
// 'func',
|
|
1037
|
+
// 'function',
|
|
1038
|
+
// 'method',
|
|
1039
|
+
// 'class',
|
|
1040
|
+
// 'constructor',
|
|
1041
|
+
// ],
|
|
1042
|
+
// },
|
|
1043
|
+
// {
|
|
1044
|
+
// // Relationships
|
|
1045
|
+
// tags: [
|
|
1046
|
+
// 'modifies',
|
|
1047
|
+
// 'mixes',
|
|
1048
|
+
// 'mixin',
|
|
1049
|
+
// 'mixinClass',
|
|
1050
|
+
// 'mixinFunction',
|
|
1051
|
+
// 'namespace',
|
|
1052
|
+
// 'borrows',
|
|
1053
|
+
// 'constructs',
|
|
1054
|
+
// 'lends',
|
|
1055
|
+
// 'implements',
|
|
1056
|
+
// 'requires',
|
|
1057
|
+
// ],
|
|
1058
|
+
// },
|
|
1059
|
+
// {
|
|
1060
|
+
// // Long descriptions
|
|
1061
|
+
// tags: ['desc', 'description', 'classdesc', 'tutorial', 'copyright', 'license'],
|
|
1062
|
+
// },
|
|
1063
|
+
// {
|
|
1064
|
+
// // Simple annotations
|
|
1065
|
+
// tags: [
|
|
1066
|
+
// 'const',
|
|
1067
|
+
// 'constant',
|
|
1068
|
+
// 'final',
|
|
1069
|
+
// 'global',
|
|
1070
|
+
// 'readonly',
|
|
1071
|
+
// 'abstract',
|
|
1072
|
+
// 'virtual',
|
|
1073
|
+
// 'var',
|
|
1074
|
+
// 'member',
|
|
1075
|
+
// 'memberof',
|
|
1076
|
+
// 'memberof!',
|
|
1077
|
+
// 'inner',
|
|
1078
|
+
// 'instance',
|
|
1079
|
+
// 'inheritdoc',
|
|
1080
|
+
// 'inheritDoc',
|
|
1081
|
+
// 'override',
|
|
1082
|
+
// 'hideconstructor',
|
|
1083
|
+
// ],
|
|
1084
|
+
// },
|
|
1085
|
+
// {
|
|
1086
|
+
// // Core function/object inf
|
|
1087
|
+
// tags: ['param', 'arg', 'argument', 'prop', 'property', 'return', 'returns'],
|
|
1088
|
+
// },
|
|
1089
|
+
// {
|
|
1090
|
+
// // Important behavior details
|
|
1091
|
+
// tags: [
|
|
1092
|
+
// 'async',
|
|
1093
|
+
// 'generator',
|
|
1094
|
+
// 'default',
|
|
1095
|
+
// 'defaultvalue',
|
|
1096
|
+
// 'enum',
|
|
1097
|
+
// 'augments',
|
|
1098
|
+
// 'extends',
|
|
1099
|
+
// 'throws',
|
|
1100
|
+
// 'exception',
|
|
1101
|
+
// 'yield',
|
|
1102
|
+
// 'yields',
|
|
1103
|
+
// 'event',
|
|
1104
|
+
// 'fires',
|
|
1105
|
+
// 'emits',
|
|
1106
|
+
// 'listens',
|
|
1107
|
+
// 'this',
|
|
1108
|
+
// ],
|
|
1109
|
+
// },
|
|
1110
|
+
// {
|
|
1111
|
+
// // Access
|
|
1112
|
+
// tags: ['static', 'private', 'protected', 'public', 'access', 'internal', 'package'],
|
|
1113
|
+
// },
|
|
1114
|
+
// {
|
|
1115
|
+
// // Other/unknown
|
|
1116
|
+
// tags: ['-other'],
|
|
1117
|
+
// },
|
|
1118
|
+
// {
|
|
1119
|
+
// // Supplementary descriptions
|
|
1120
|
+
// tags: ['see', 'example'],
|
|
1121
|
+
// },
|
|
1122
|
+
// {
|
|
1123
|
+
// // Other Closure (undocumented) metadata
|
|
1124
|
+
// tags: [
|
|
1125
|
+
// 'closurePrimitive',
|
|
1126
|
+
// 'customElement',
|
|
1127
|
+
// 'expose',
|
|
1128
|
+
// 'hidden',
|
|
1129
|
+
// 'idGenerator',
|
|
1130
|
+
// 'meaning',
|
|
1131
|
+
// 'ngInject',
|
|
1132
|
+
// 'owner',
|
|
1133
|
+
// 'wizaction',
|
|
1134
|
+
// ],
|
|
1135
|
+
// },
|
|
1136
|
+
// {
|
|
1137
|
+
// // Other Closure (documented) metadata
|
|
1138
|
+
// tags: [
|
|
1139
|
+
// 'define',
|
|
1140
|
+
// 'dict',
|
|
1141
|
+
// 'export',
|
|
1142
|
+
// 'externs',
|
|
1143
|
+
// 'implicitCast',
|
|
1144
|
+
// 'noalias',
|
|
1145
|
+
// 'nocollapse',
|
|
1146
|
+
// 'nocompile',
|
|
1147
|
+
// 'noinline',
|
|
1148
|
+
// 'nosideeffects',
|
|
1149
|
+
// 'polymer',
|
|
1150
|
+
// 'polymerBehavior',
|
|
1151
|
+
// 'preserve',
|
|
1152
|
+
// 'struct',
|
|
1153
|
+
// 'suppress',
|
|
1154
|
+
// 'unrestricted',
|
|
1155
|
+
// ],
|
|
1156
|
+
// },
|
|
1157
|
+
// {
|
|
1158
|
+
// // Metadata
|
|
1159
|
+
// tags: ['category'],
|
|
1160
|
+
// },
|
|
1161
|
+
// {
|
|
1162
|
+
// // Non-Closure metadata
|
|
1163
|
+
// tags: [
|
|
1164
|
+
// 'ignore',
|
|
1165
|
+
// 'author',
|
|
1166
|
+
// 'version',
|
|
1167
|
+
// 'variation',
|
|
1168
|
+
// 'since',
|
|
1169
|
+
// 'deprecated',
|
|
1170
|
+
// 'compatibility',
|
|
1171
|
+
// 'todo',
|
|
1172
|
+
// ],
|
|
1173
|
+
// },
|
|
1174
|
+
// ],
|
|
1175
|
+
// alphabetizeExtras: true,
|
|
1176
|
+
// linesBetween: 1,
|
|
1177
|
+
// },
|
|
1178
|
+
// ],
|
|
978
1179
|
"jsdoc/check-access": "warn",
|
|
979
|
-
"jsdoc/check-param-names": "warn",
|
|
980
|
-
"jsdoc/check-property-names": "warn",
|
|
981
|
-
"jsdoc/check-types": "warn",
|
|
982
|
-
"jsdoc/empty-tags": "warn",
|
|
983
1180
|
"jsdoc/implements-on-classes": "warn",
|
|
984
|
-
"jsdoc/no-defaults": "warn",
|
|
985
|
-
"jsdoc/no-multi-asterisks": "warn",
|
|
986
1181
|
"jsdoc/require-param-name": "warn",
|
|
987
1182
|
"jsdoc/require-property": "warn",
|
|
988
|
-
"jsdoc/require-property-description": "warn",
|
|
989
1183
|
"jsdoc/require-property-name": "warn",
|
|
1184
|
+
"jsdoc/require-property-description": "warn",
|
|
990
1185
|
"jsdoc/require-returns-check": "warn",
|
|
991
1186
|
"jsdoc/require-returns-description": "warn",
|
|
992
1187
|
"jsdoc/require-yields-check": "warn",
|
|
993
|
-
|
|
994
|
-
|
|
1188
|
+
// TypeScript rules overrides
|
|
1189
|
+
...options.typescript ? typescriptRules : {},
|
|
995
1190
|
// Overrides rules
|
|
996
1191
|
...options.overrides
|
|
997
1192
|
}
|
|
@@ -1011,10 +1206,12 @@ var jsonc = (options = {}) => [
|
|
|
1011
1206
|
},
|
|
1012
1207
|
rules: {
|
|
1013
1208
|
...default10.configs["recommended-with-jsonc"].rules,
|
|
1014
|
-
"jsonc/
|
|
1015
|
-
"jsonc/comma-dangle": ["error", "never"],
|
|
1016
|
-
"jsonc/comma-style": ["error", "last"],
|
|
1209
|
+
"jsonc/no-octal-escape": "error",
|
|
1017
1210
|
"jsonc/indent": ["error", 2],
|
|
1211
|
+
"jsonc/comma-style": ["error", "last"],
|
|
1212
|
+
"jsonc/comma-dangle": ["error", "never"],
|
|
1213
|
+
"jsonc/object-curly-spacing": ["error", "always"],
|
|
1214
|
+
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
1018
1215
|
"jsonc/key-spacing": [
|
|
1019
1216
|
"error",
|
|
1020
1217
|
{
|
|
@@ -1022,7 +1219,6 @@ var jsonc = (options = {}) => [
|
|
|
1022
1219
|
afterColon: true
|
|
1023
1220
|
}
|
|
1024
1221
|
],
|
|
1025
|
-
"jsonc/no-octal-escape": "error",
|
|
1026
1222
|
"jsonc/object-curly-newline": [
|
|
1027
1223
|
"error",
|
|
1028
1224
|
{
|
|
@@ -1030,7 +1226,6 @@ var jsonc = (options = {}) => [
|
|
|
1030
1226
|
consistent: true
|
|
1031
1227
|
}
|
|
1032
1228
|
],
|
|
1033
|
-
"jsonc/object-curly-spacing": ["error", "always"],
|
|
1034
1229
|
"jsonc/object-property-newline": [
|
|
1035
1230
|
"error",
|
|
1036
1231
|
{
|
|
@@ -1060,23 +1255,23 @@ var ntnyq = (options = {}) => [
|
|
|
1060
1255
|
|
|
1061
1256
|
// src/configs/regexp.ts
|
|
1062
1257
|
var regexp = (options = {}) => {
|
|
1063
|
-
const
|
|
1064
|
-
const
|
|
1065
|
-
...
|
|
1258
|
+
const recommendedConfig = pluginRegexp.configs["flat/recommended"];
|
|
1259
|
+
const recommendedRules2 = {
|
|
1260
|
+
...recommendedConfig.rules
|
|
1066
1261
|
};
|
|
1067
1262
|
if (options.level === "warn") {
|
|
1068
|
-
for (const key in
|
|
1069
|
-
if (
|
|
1070
|
-
|
|
1263
|
+
for (const key in recommendedRules2) {
|
|
1264
|
+
if (recommendedRules2[key] === "error") {
|
|
1265
|
+
recommendedRules2[key] = "warn";
|
|
1071
1266
|
}
|
|
1072
1267
|
}
|
|
1073
1268
|
}
|
|
1074
1269
|
return [
|
|
1075
1270
|
{
|
|
1076
|
-
...
|
|
1271
|
+
...recommendedConfig,
|
|
1077
1272
|
name: "ntnyq/regexp",
|
|
1078
1273
|
rules: {
|
|
1079
|
-
...
|
|
1274
|
+
...recommendedRules2,
|
|
1080
1275
|
// Overrides rules
|
|
1081
1276
|
...options.overrides
|
|
1082
1277
|
}
|
|
@@ -1351,8 +1546,8 @@ var imports = (options = {}) => [
|
|
|
1351
1546
|
// src/configs/unicorn.ts
|
|
1352
1547
|
var disabledRules2 = {
|
|
1353
1548
|
"unicorn/better-regex": "off",
|
|
1354
|
-
"unicorn/prefer-top-level-await": "off",
|
|
1355
1549
|
"unicorn/explicit-length-check": "off",
|
|
1550
|
+
"unicorn/prefer-top-level-await": "off",
|
|
1356
1551
|
"unicorn/no-array-callback-reference": "off",
|
|
1357
1552
|
/**
|
|
1358
1553
|
* @see https://caniuse.com/?search=globalThis
|
|
@@ -1366,37 +1561,37 @@ var unicorn = (options = {}) => [
|
|
|
1366
1561
|
unicorn: default15
|
|
1367
1562
|
},
|
|
1368
1563
|
rules: {
|
|
1369
|
-
"unicorn/error-message": "error",
|
|
1370
1564
|
"unicorn/escape-case": "error",
|
|
1565
|
+
"unicorn/no-for-loop": "error",
|
|
1566
|
+
"unicorn/no-lonely-if": "error",
|
|
1567
|
+
"unicorn/error-message": "error",
|
|
1371
1568
|
"unicorn/no-new-buffer": "error",
|
|
1372
|
-
"unicorn/
|
|
1569
|
+
"unicorn/no-hex-escape": "error",
|
|
1570
|
+
"unicorn/throw-new-error": "error",
|
|
1373
1571
|
"unicorn/prefer-includes": "error",
|
|
1572
|
+
"unicorn/new-for-builtins": "error",
|
|
1374
1573
|
"unicorn/prefer-type-error": "error",
|
|
1375
|
-
"unicorn/
|
|
1376
|
-
"unicorn/no-
|
|
1377
|
-
"unicorn/
|
|
1378
|
-
"unicorn/no-typeof-undefined": "error",
|
|
1574
|
+
"unicorn/prefer-math-trunc": "error",
|
|
1575
|
+
"unicorn/no-console-spaces": "error",
|
|
1576
|
+
"unicorn/no-zero-fractions": "error",
|
|
1379
1577
|
"unicorn/prefer-regexp-test": "error",
|
|
1578
|
+
"unicorn/number-literal-case": "error",
|
|
1579
|
+
"unicorn/no-typeof-undefined": "error",
|
|
1580
|
+
"unicorn/prefer-math-min-max": "error",
|
|
1581
|
+
"unicorn/prefer-node-protocol": "error",
|
|
1582
|
+
"unicorn/no-unnecessary-await": "error",
|
|
1380
1583
|
"unicorn/no-static-only-class": "error",
|
|
1381
|
-
"unicorn/
|
|
1584
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1585
|
+
"unicorn/prefer-negative-index": "error",
|
|
1586
|
+
"unicorn/prefer-structured-clone": "error",
|
|
1382
1587
|
"unicorn/custom-error-definition": "error",
|
|
1383
1588
|
"unicorn/prefer-modern-math-apis": "error",
|
|
1384
|
-
"unicorn/new-for-builtins": "error",
|
|
1385
|
-
"unicorn/no-console-spaces": "error",
|
|
1386
|
-
"unicorn/no-for-loop": "error",
|
|
1387
|
-
"unicorn/no-hex-escape": "error",
|
|
1388
|
-
"unicorn/no-lonely-if": "error",
|
|
1389
|
-
"unicorn/prefer-keyboard-event-key": "error",
|
|
1390
|
-
"unicorn/prefer-math-trunc": "error",
|
|
1391
|
-
"unicorn/prefer-negative-index": "error",
|
|
1392
|
-
"unicorn/prefer-node-protocol": "error",
|
|
1393
1589
|
"unicorn/prefer-number-properties": "error",
|
|
1394
|
-
"unicorn/prefer-optional-catch-binding": "error",
|
|
1395
1590
|
"unicorn/prefer-prototype-methods": "error",
|
|
1396
|
-
"unicorn/prefer-
|
|
1397
|
-
"unicorn/prefer-
|
|
1398
|
-
"unicorn/prefer-structured-clone": "error",
|
|
1591
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
1592
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1399
1593
|
"unicorn/consistent-existence-index-check": "error",
|
|
1594
|
+
"unicorn/switch-case-braces": ["error", "avoid"],
|
|
1400
1595
|
"unicorn/catch-error-name": [
|
|
1401
1596
|
"error",
|
|
1402
1597
|
{
|
|
@@ -1411,24 +1606,24 @@ var unicorn = (options = {}) => [
|
|
|
1411
1606
|
"unicorn/prefer-string-trim-start-end": "error",
|
|
1412
1607
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1413
1608
|
// DOM
|
|
1414
|
-
"unicorn/prefer-add-event-listener": "error",
|
|
1415
|
-
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1416
1609
|
"unicorn/prefer-query-selector": "error",
|
|
1417
1610
|
"unicorn/prefer-modern-dom-apis": "error",
|
|
1611
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
1418
1612
|
"unicorn/prefer-dom-node-append": "error",
|
|
1419
1613
|
"unicorn/prefer-dom-node-dataset": "error",
|
|
1420
|
-
"unicorn/prefer-
|
|
1614
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
1421
1615
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
1616
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1422
1617
|
// Array
|
|
1423
1618
|
"unicorn/no-new-array": "error",
|
|
1424
|
-
"unicorn/no-instanceof-array": "error",
|
|
1425
1619
|
"unicorn/no-array-push-push": "error",
|
|
1426
|
-
"unicorn/no-array-method-this-argument": "error",
|
|
1427
1620
|
"unicorn/prefer-array-find": "error",
|
|
1428
1621
|
"unicorn/prefer-array-some": "error",
|
|
1622
|
+
"unicorn/no-instanceof-array": "error",
|
|
1429
1623
|
"unicorn/prefer-array-flat-map": "error",
|
|
1430
1624
|
"unicorn/prefer-array-index-of": "error",
|
|
1431
1625
|
"unicorn/require-array-join-separator": "error",
|
|
1626
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
1432
1627
|
// Set
|
|
1433
1628
|
"unicorn/prefer-set-has": "error",
|
|
1434
1629
|
"unicorn/prefer-set-size": "error",
|
|
@@ -1441,13 +1636,15 @@ var unicorn = (options = {}) => [
|
|
|
1441
1636
|
|
|
1442
1637
|
// src/configs/specials.ts
|
|
1443
1638
|
import globals from "globals";
|
|
1444
|
-
var specials = () => [
|
|
1639
|
+
var specials = (options = {}) => [
|
|
1445
1640
|
{
|
|
1446
1641
|
name: "ntnyq/specials/scripts",
|
|
1447
1642
|
files: [`**/scripts/${GLOB_SRC}`],
|
|
1448
1643
|
rules: {
|
|
1449
1644
|
"no-console": "off",
|
|
1450
|
-
"@typescript-eslint/explicit-function-return-type": "off"
|
|
1645
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1646
|
+
// Overrides rules
|
|
1647
|
+
...options.overridesScriptsRules
|
|
1451
1648
|
}
|
|
1452
1649
|
},
|
|
1453
1650
|
{
|
|
@@ -1455,7 +1652,9 @@ var specials = () => [
|
|
|
1455
1652
|
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
1456
1653
|
rules: {
|
|
1457
1654
|
"no-console": "off",
|
|
1458
|
-
"@typescript-eslint/explicit-function-return-type": "off"
|
|
1655
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
1656
|
+
// Overrides rules
|
|
1657
|
+
...options.overridesCliRules
|
|
1459
1658
|
}
|
|
1460
1659
|
},
|
|
1461
1660
|
{
|
|
@@ -1472,9 +1671,14 @@ var specials = () => [
|
|
|
1472
1671
|
{
|
|
1473
1672
|
allow: ["^GM_.+"]
|
|
1474
1673
|
}
|
|
1475
|
-
]
|
|
1674
|
+
],
|
|
1675
|
+
// Overrides rules
|
|
1676
|
+
...options.overridesUserScriptsRules
|
|
1476
1677
|
}
|
|
1477
|
-
}
|
|
1678
|
+
},
|
|
1679
|
+
// More special case configs
|
|
1680
|
+
// So don't need to append configs to composer
|
|
1681
|
+
...options.specialCaseConfigs ? options.specialCaseConfigs : []
|
|
1478
1682
|
];
|
|
1479
1683
|
|
|
1480
1684
|
// src/configs/comments.ts
|
|
@@ -1496,14 +1700,43 @@ var comments = (options = {}) => [
|
|
|
1496
1700
|
// src/configs/markdown.ts
|
|
1497
1701
|
var markdown = (options = {}) => {
|
|
1498
1702
|
if (!Array.isArray(default7.configs?.processor)) return [];
|
|
1703
|
+
const { files = [`${GLOB_MARKDOWN}/${GLOB_SRC}`], extensions = [] } = options;
|
|
1499
1704
|
return [
|
|
1500
1705
|
...default7.configs.processor.map((config) => ({
|
|
1501
1706
|
...config,
|
|
1502
1707
|
name: `ntnyq/${config.name}`
|
|
1503
1708
|
})),
|
|
1709
|
+
{
|
|
1710
|
+
name: "ntnyq/markdown/processor",
|
|
1711
|
+
files,
|
|
1712
|
+
ignores: [GLOB_MARKDOWN_NESTED],
|
|
1713
|
+
processor: mergeProcessors([
|
|
1714
|
+
default7.processors.markdown,
|
|
1715
|
+
// Just pass through processor
|
|
1716
|
+
processorPassThrough
|
|
1717
|
+
])
|
|
1718
|
+
},
|
|
1719
|
+
{
|
|
1720
|
+
name: "ntnyq/markdown/parser",
|
|
1721
|
+
files,
|
|
1722
|
+
languageOptions: {
|
|
1723
|
+
parser: parserPlain
|
|
1724
|
+
}
|
|
1725
|
+
},
|
|
1504
1726
|
{
|
|
1505
1727
|
name: "ntnyq/markdown/disabled/code-blocks",
|
|
1506
|
-
files: [
|
|
1728
|
+
files: [
|
|
1729
|
+
...files,
|
|
1730
|
+
// Extension block support
|
|
1731
|
+
...extensions.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
|
|
1732
|
+
],
|
|
1733
|
+
languageOptions: {
|
|
1734
|
+
parserOptions: {
|
|
1735
|
+
ecmaFeatures: {
|
|
1736
|
+
impliedStrict: true
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
},
|
|
1507
1740
|
rules: {
|
|
1508
1741
|
"no-undef": "off",
|
|
1509
1742
|
"no-alert": "off",
|
|
@@ -1536,6 +1769,7 @@ var markdown = (options = {}) => {
|
|
|
1536
1769
|
var prettier = (options = {}) => {
|
|
1537
1770
|
const {
|
|
1538
1771
|
disabledFiles = [GLOB_TOML, GLOB_ASTRO, GLOB_SVELTE],
|
|
1772
|
+
// User defined disabled files
|
|
1539
1773
|
userDisabledFiles = []
|
|
1540
1774
|
} = options;
|
|
1541
1775
|
return [
|
|
@@ -1902,14 +2136,21 @@ var recommendedRules = configs.recommended.reduce((rules, config) => {
|
|
|
1902
2136
|
var typescript = (options = {}) => {
|
|
1903
2137
|
const enableTypeAwareLint = !!options?.tsconfigPath;
|
|
1904
2138
|
const {
|
|
2139
|
+
extensions = [],
|
|
1905
2140
|
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1906
2141
|
ignoresTypeAware = [GLOB_ASTRO, `${GLOB_MARKDOWN}/**`],
|
|
1907
2142
|
overridesTypeAwareRules = {},
|
|
1908
2143
|
parserOptions = {}
|
|
1909
2144
|
} = options;
|
|
1910
|
-
|
|
2145
|
+
const files = options.files ?? [
|
|
2146
|
+
GLOB_TS,
|
|
2147
|
+
GLOB_TSX,
|
|
2148
|
+
// Enable typescript in these exts
|
|
2149
|
+
...extensions.map((ext) => `**/*.${ext}`)
|
|
2150
|
+
];
|
|
2151
|
+
function createParserConfig(enableTypeAware = false, files2 = [], ignores2 = []) {
|
|
1911
2152
|
const typescriptParserOptions = {
|
|
1912
|
-
|
|
2153
|
+
extraFileExtensions: extensions.map((ext) => `.${ext}`),
|
|
1913
2154
|
sourceType: "module",
|
|
1914
2155
|
...enableTypeAware ? {
|
|
1915
2156
|
projectService: {
|
|
@@ -1922,7 +2163,7 @@ var typescript = (options = {}) => {
|
|
|
1922
2163
|
};
|
|
1923
2164
|
const parserConfig = {
|
|
1924
2165
|
name: `ntnyq/ts/${enableTypeAware ? "parser-type-aware" : "parser"}`,
|
|
1925
|
-
files,
|
|
2166
|
+
files: files2,
|
|
1926
2167
|
ignores: [...ignores2],
|
|
1927
2168
|
languageOptions: {
|
|
1928
2169
|
parser: parserTypeScript,
|
|
@@ -1940,12 +2181,12 @@ var typescript = (options = {}) => {
|
|
|
1940
2181
|
}
|
|
1941
2182
|
},
|
|
1942
2183
|
...enableTypeAwareLint ? [
|
|
1943
|
-
createParserConfig(false,
|
|
2184
|
+
createParserConfig(false, files),
|
|
1944
2185
|
createParserConfig(true, filesTypeAware, ignoresTypeAware)
|
|
1945
|
-
] : [createParserConfig(false,
|
|
2186
|
+
] : [createParserConfig(false, files)],
|
|
1946
2187
|
{
|
|
1947
2188
|
name: "ntnyq/ts/rules",
|
|
1948
|
-
files
|
|
2189
|
+
files,
|
|
1949
2190
|
rules: {
|
|
1950
2191
|
...recommendedRules,
|
|
1951
2192
|
// Disabled in favor of ts rules
|
|
@@ -2188,9 +2429,41 @@ var unusedImports = (options = {}) => [
|
|
|
2188
2429
|
];
|
|
2189
2430
|
|
|
2190
2431
|
// src/core.ts
|
|
2191
|
-
|
|
2432
|
+
function defineESLintConfig(options = {}, ...userConfigs) {
|
|
2433
|
+
const {
|
|
2434
|
+
/**
|
|
2435
|
+
* Shared options
|
|
2436
|
+
*/
|
|
2437
|
+
extensions: supportedExtensions = [],
|
|
2438
|
+
/**
|
|
2439
|
+
* Conditional by deps
|
|
2440
|
+
*/
|
|
2441
|
+
vue: enableVue = hasVue,
|
|
2442
|
+
test: enableTest = hasVitest,
|
|
2443
|
+
unocss: enableUnoCSS = hasUnoCSS,
|
|
2444
|
+
typescript: enableTypeScript = hasTypeScript,
|
|
2445
|
+
/**
|
|
2446
|
+
* Enabled by default
|
|
2447
|
+
*/
|
|
2448
|
+
yml: enableYML = true,
|
|
2449
|
+
sort: enableSort = true,
|
|
2450
|
+
toml: enableTOML = true,
|
|
2451
|
+
jsonc: enableJSONC = true,
|
|
2452
|
+
antfu: enableAntfu = true,
|
|
2453
|
+
regexp: enableRegexp = true,
|
|
2454
|
+
unicorn: enableUnicorn = true,
|
|
2455
|
+
prettier: enablePrettier = true,
|
|
2456
|
+
markdown: enableMarkdown = true,
|
|
2457
|
+
stylistic: enableStylistic = true,
|
|
2458
|
+
gitignore: enableGitIgnore = true,
|
|
2459
|
+
githubAction: enableGitHubAction = true,
|
|
2460
|
+
perfectionist: enablePerfectionist = true
|
|
2461
|
+
} = options;
|
|
2192
2462
|
const configs2 = [];
|
|
2193
|
-
if (
|
|
2463
|
+
if (enableVue) {
|
|
2464
|
+
supportedExtensions.push("vue");
|
|
2465
|
+
}
|
|
2466
|
+
if (enableGitIgnore) {
|
|
2194
2467
|
configs2.push(
|
|
2195
2468
|
...gitignore({
|
|
2196
2469
|
...resolveSubOptions(options, "gitignore")
|
|
@@ -2210,6 +2483,7 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2210
2483
|
overrides: getOverrides(options, "imports")
|
|
2211
2484
|
}),
|
|
2212
2485
|
...jsdoc({
|
|
2486
|
+
typescript: !!enableTypeScript,
|
|
2213
2487
|
overrides: getOverrides(options, "jsdoc")
|
|
2214
2488
|
}),
|
|
2215
2489
|
...comments({
|
|
@@ -2220,7 +2494,7 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2220
2494
|
overrides: getOverrides(options, "javascript")
|
|
2221
2495
|
})
|
|
2222
2496
|
);
|
|
2223
|
-
if (
|
|
2497
|
+
if (enablePerfectionist) {
|
|
2224
2498
|
configs2.push(
|
|
2225
2499
|
...perfectionist({
|
|
2226
2500
|
...resolveSubOptions(options, "perfectionist"),
|
|
@@ -2228,14 +2502,14 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2228
2502
|
})
|
|
2229
2503
|
);
|
|
2230
2504
|
}
|
|
2231
|
-
if (
|
|
2505
|
+
if (enableUnicorn) {
|
|
2232
2506
|
configs2.push(
|
|
2233
2507
|
...unicorn({
|
|
2234
2508
|
overrides: getOverrides(options, "unicorn")
|
|
2235
2509
|
})
|
|
2236
2510
|
);
|
|
2237
2511
|
}
|
|
2238
|
-
if (
|
|
2512
|
+
if (enableRegexp) {
|
|
2239
2513
|
configs2.push(
|
|
2240
2514
|
...regexp({
|
|
2241
2515
|
...resolveSubOptions(options, "regexp"),
|
|
@@ -2243,51 +2517,53 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2243
2517
|
})
|
|
2244
2518
|
);
|
|
2245
2519
|
}
|
|
2246
|
-
if (
|
|
2520
|
+
if (enableTypeScript) {
|
|
2247
2521
|
configs2.push(
|
|
2248
2522
|
...typescript({
|
|
2249
2523
|
...resolveSubOptions(options, "typescript"),
|
|
2524
|
+
extensions: supportedExtensions,
|
|
2250
2525
|
overrides: getOverrides(options, "typescript")
|
|
2251
2526
|
})
|
|
2252
2527
|
);
|
|
2253
2528
|
}
|
|
2254
|
-
if (
|
|
2529
|
+
if (enableVue) {
|
|
2530
|
+
configs2.push(
|
|
2531
|
+
...vue({
|
|
2532
|
+
...resolveSubOptions(options, "vue"),
|
|
2533
|
+
typescript: !!enableTypeScript,
|
|
2534
|
+
overrides: getOverrides(options, "vue")
|
|
2535
|
+
})
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2538
|
+
if (enableYML) {
|
|
2255
2539
|
configs2.push(
|
|
2256
2540
|
...yml({
|
|
2257
2541
|
overrides: getOverrides(options, "yml")
|
|
2258
2542
|
})
|
|
2259
2543
|
);
|
|
2260
2544
|
}
|
|
2261
|
-
if (
|
|
2545
|
+
if (enableTOML) {
|
|
2262
2546
|
configs2.push(
|
|
2263
2547
|
...toml({
|
|
2264
2548
|
overrides: getOverrides(options, "toml")
|
|
2265
2549
|
})
|
|
2266
2550
|
);
|
|
2267
2551
|
}
|
|
2268
|
-
if (
|
|
2552
|
+
if (enableJSONC) {
|
|
2269
2553
|
configs2.push(
|
|
2270
2554
|
...jsonc({
|
|
2271
2555
|
overrides: getOverrides(options, "jsonc")
|
|
2272
2556
|
})
|
|
2273
2557
|
);
|
|
2274
2558
|
}
|
|
2275
|
-
if (
|
|
2559
|
+
if (enableSort) {
|
|
2276
2560
|
configs2.push(
|
|
2277
2561
|
...sort({
|
|
2278
2562
|
...resolveSubOptions(options, "sort")
|
|
2279
2563
|
})
|
|
2280
2564
|
);
|
|
2281
2565
|
}
|
|
2282
|
-
if (
|
|
2283
|
-
configs2.push(
|
|
2284
|
-
...vue({
|
|
2285
|
-
...resolveSubOptions(options, "vue"),
|
|
2286
|
-
overrides: getOverrides(options, "vue")
|
|
2287
|
-
})
|
|
2288
|
-
);
|
|
2289
|
-
}
|
|
2290
|
-
if (options.test ?? hasVitest) {
|
|
2566
|
+
if (enableTest) {
|
|
2291
2567
|
configs2.push(
|
|
2292
2568
|
...test({
|
|
2293
2569
|
overrides: getOverrides(options, "test")
|
|
@@ -2297,48 +2573,50 @@ async function defineESLintConfig(options = {}, ...userConfigs) {
|
|
|
2297
2573
|
})
|
|
2298
2574
|
);
|
|
2299
2575
|
}
|
|
2300
|
-
if (
|
|
2576
|
+
if (enableUnoCSS) {
|
|
2301
2577
|
configs2.push(
|
|
2302
2578
|
...unocss({
|
|
2303
2579
|
overrides: getOverrides(options, "unocss")
|
|
2304
2580
|
})
|
|
2305
2581
|
);
|
|
2306
2582
|
}
|
|
2307
|
-
if (
|
|
2583
|
+
if (enableMarkdown) {
|
|
2308
2584
|
configs2.push(
|
|
2309
2585
|
...markdown({
|
|
2586
|
+
extensions: supportedExtensions,
|
|
2310
2587
|
overrides: getOverrides(options, "markdown")
|
|
2311
2588
|
})
|
|
2312
2589
|
);
|
|
2313
2590
|
}
|
|
2314
|
-
if (
|
|
2591
|
+
if (enableAntfu) {
|
|
2315
2592
|
configs2.push(
|
|
2316
2593
|
...antfu({
|
|
2317
2594
|
overrides: getOverrides(options, "antfu")
|
|
2318
2595
|
})
|
|
2319
2596
|
);
|
|
2320
2597
|
}
|
|
2321
|
-
if (
|
|
2598
|
+
if (enableStylistic) {
|
|
2322
2599
|
configs2.push(
|
|
2323
2600
|
...stylistic({
|
|
2324
2601
|
overrides: getOverrides(options, "stylistic")
|
|
2325
2602
|
})
|
|
2326
2603
|
);
|
|
2327
2604
|
}
|
|
2328
|
-
if (
|
|
2605
|
+
if (enableGitHubAction) {
|
|
2329
2606
|
configs2.push(
|
|
2330
2607
|
...githubAction({
|
|
2331
2608
|
overrides: getOverrides(options, "githubAction")
|
|
2332
2609
|
})
|
|
2333
2610
|
);
|
|
2334
2611
|
}
|
|
2335
|
-
const configSpecials = specials(
|
|
2336
|
-
|
|
2612
|
+
const configSpecials = specials({
|
|
2613
|
+
...resolveSubOptions(options, "specials")
|
|
2614
|
+
});
|
|
2615
|
+
const configPrettier = enablePrettier ? prettier({
|
|
2337
2616
|
...resolveSubOptions(options, "prettier"),
|
|
2338
2617
|
overrides: getOverrides(options, "prettier")
|
|
2339
2618
|
}) : [];
|
|
2340
|
-
const composer = new FlatConfigComposer(
|
|
2341
|
-
await composer.append(
|
|
2619
|
+
const composer = new FlatConfigComposer(
|
|
2342
2620
|
...configs2,
|
|
2343
2621
|
...userConfigs,
|
|
2344
2622
|
...configSpecials,
|