@coderwyd/eslint-config 2.1.2 → 2.1.4
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/README.md +1 -1
- package/dist/cli.cjs +6 -6
- package/dist/cli.js +6 -6
- package/dist/index.cjs +55 -17
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -17
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "2.1.
|
|
49
|
+
var version = "2.1.4";
|
|
50
50
|
var devDependencies = {
|
|
51
51
|
"@antfu/ni": "^0.21.12",
|
|
52
52
|
"@types/eslint": "^8.56.2",
|
|
@@ -117,7 +117,7 @@ function isGitClean() {
|
|
|
117
117
|
try {
|
|
118
118
|
(0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
|
|
119
119
|
return true;
|
|
120
|
-
} catch
|
|
120
|
+
} catch {
|
|
121
121
|
return false;
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -167,7 +167,7 @@ async function run(options = {}) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
let eslintConfigContent = "";
|
|
170
|
-
const coderwydConfig = `${eslintIgnores.length ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
170
|
+
const coderwydConfig = `${eslintIgnores.length > 0 ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
171
171
|
if (pkg.type === "module") {
|
|
172
172
|
eslintConfigContent = `
|
|
173
173
|
import { defineConfig } from '@coderwyd/eslint-config'
|
|
@@ -193,7 +193,7 @@ ${coderwydConfig}
|
|
|
193
193
|
if (file.includes("eslint") || file.includes("prettier"))
|
|
194
194
|
legacyConfig.push(file);
|
|
195
195
|
});
|
|
196
|
-
if (legacyConfig.length) {
|
|
196
|
+
if (legacyConfig.length > 0) {
|
|
197
197
|
console.log(`${WARN} you can now remove those files manually:`);
|
|
198
198
|
console.log(` ${import_picocolors2.default.dim(legacyConfig.join(", "))}`);
|
|
199
199
|
}
|
|
@@ -215,8 +215,8 @@ ${coderwydConfig}
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
);
|
|
218
|
-
} catch (
|
|
219
|
-
console.log(
|
|
218
|
+
} catch (error) {
|
|
219
|
+
console.log(error.message);
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
222
|
}
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "2.1.
|
|
20
|
+
var version = "2.1.4";
|
|
21
21
|
var devDependencies = {
|
|
22
22
|
"@antfu/ni": "^0.21.12",
|
|
23
23
|
"@types/eslint": "^8.56.2",
|
|
@@ -88,7 +88,7 @@ function isGitClean() {
|
|
|
88
88
|
try {
|
|
89
89
|
execSync("git diff-index --quiet HEAD --");
|
|
90
90
|
return true;
|
|
91
|
-
} catch
|
|
91
|
+
} catch {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -138,7 +138,7 @@ async function run(options = {}) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
let eslintConfigContent = "";
|
|
141
|
-
const coderwydConfig = `${eslintIgnores.length ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
141
|
+
const coderwydConfig = `${eslintIgnores.length > 0 ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
142
142
|
if (pkg.type === "module") {
|
|
143
143
|
eslintConfigContent = `
|
|
144
144
|
import { defineConfig } from '@coderwyd/eslint-config'
|
|
@@ -164,7 +164,7 @@ ${coderwydConfig}
|
|
|
164
164
|
if (file.includes("eslint") || file.includes("prettier"))
|
|
165
165
|
legacyConfig.push(file);
|
|
166
166
|
});
|
|
167
|
-
if (legacyConfig.length) {
|
|
167
|
+
if (legacyConfig.length > 0) {
|
|
168
168
|
console.log(`${WARN} you can now remove those files manually:`);
|
|
169
169
|
console.log(` ${c2.dim(legacyConfig.join(", "))}`);
|
|
170
170
|
}
|
|
@@ -186,8 +186,8 @@ ${coderwydConfig}
|
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
);
|
|
189
|
-
} catch (
|
|
190
|
-
console.log(
|
|
189
|
+
} catch (error) {
|
|
190
|
+
console.log(error.message);
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
193
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ var import_local_pkg3 = require("local-pkg");
|
|
|
41
41
|
var DEFAULT_PRETTIER_RULES = {
|
|
42
42
|
arrowParens: "avoid",
|
|
43
43
|
htmlWhitespaceSensitivity: "ignore",
|
|
44
|
-
printWidth:
|
|
44
|
+
printWidth: 80,
|
|
45
45
|
semi: false,
|
|
46
46
|
singleQuote: true
|
|
47
47
|
};
|
|
@@ -987,31 +987,64 @@ async function unicorn() {
|
|
|
987
987
|
},
|
|
988
988
|
rules: {
|
|
989
989
|
"unicorn/better-regex": "error",
|
|
990
|
-
|
|
990
|
+
"unicorn/catch-error-name": "error",
|
|
991
|
+
"unicorn/custom-error-definition": "error",
|
|
991
992
|
"unicorn/error-message": "error",
|
|
992
|
-
// Uppercase regex escapes
|
|
993
993
|
"unicorn/escape-case": "error",
|
|
994
|
-
|
|
994
|
+
"unicorn/explicit-length-check": "error",
|
|
995
|
+
// 'unicorn/filename-case': [
|
|
996
|
+
// 'error',
|
|
997
|
+
// {
|
|
998
|
+
// cases: { kebabCase: true, pascalCase: true },
|
|
999
|
+
// ignore: [/^[A-Z]+\..*$/],
|
|
1000
|
+
// },
|
|
1001
|
+
// ],
|
|
1002
|
+
"unicorn/new-for-builtins": "error",
|
|
1003
|
+
"unicorn/no-array-callback-reference": "error",
|
|
1004
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
1005
|
+
"unicorn/no-array-push-push": "error",
|
|
1006
|
+
"unicorn/no-console-spaces": "error",
|
|
1007
|
+
"unicorn/no-for-loop": "error",
|
|
1008
|
+
"unicorn/no-hex-escape": "error",
|
|
995
1009
|
"unicorn/no-instanceof-array": "error",
|
|
996
|
-
|
|
1010
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
1011
|
+
"unicorn/no-lonely-if": "error",
|
|
997
1012
|
"unicorn/no-new-array": "error",
|
|
998
|
-
// Prevent deprecated `new Buffer()`
|
|
999
1013
|
"unicorn/no-new-buffer": "error",
|
|
1000
|
-
|
|
1001
|
-
"unicorn/
|
|
1002
|
-
|
|
1014
|
+
"unicorn/no-static-only-class": "error",
|
|
1015
|
+
"unicorn/no-unnecessary-await": "error",
|
|
1016
|
+
"unicorn/no-zero-fractions": `error`,
|
|
1017
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
1018
|
+
"unicorn/prefer-array-find": "error",
|
|
1019
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
1020
|
+
"unicorn/prefer-array-index-of": "error",
|
|
1021
|
+
"unicorn/prefer-array-some": "error",
|
|
1022
|
+
"unicorn/prefer-at": "error",
|
|
1023
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
1024
|
+
"unicorn/prefer-date-now": "error",
|
|
1025
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
1026
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
1027
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
1003
1028
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
1004
|
-
// includes over indexOf when checking for existence
|
|
1005
1029
|
"unicorn/prefer-includes": "error",
|
|
1006
|
-
|
|
1030
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
1031
|
+
"unicorn/prefer-math-trunc": "error",
|
|
1032
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
1033
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
1034
|
+
"unicorn/prefer-negative-index": "error",
|
|
1007
1035
|
"unicorn/prefer-node-protocol": "error",
|
|
1008
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
1009
1036
|
"unicorn/prefer-number-properties": "error",
|
|
1010
|
-
|
|
1037
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1038
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1039
|
+
"unicorn/prefer-query-selector": "error",
|
|
1040
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1041
|
+
"unicorn/prefer-regexp-test": "error",
|
|
1042
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
1043
|
+
"unicorn/prefer-string-slice": "error",
|
|
1011
1044
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
1012
|
-
|
|
1045
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
1046
|
+
"unicorn/prefer-top-level-await": "error",
|
|
1013
1047
|
"unicorn/prefer-type-error": "error",
|
|
1014
|
-
// Use new when throwing error
|
|
1015
1048
|
"unicorn/throw-new-error": "error"
|
|
1016
1049
|
}
|
|
1017
1050
|
}
|
|
@@ -1291,6 +1324,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1291
1324
|
...prettierRules2,
|
|
1292
1325
|
parser
|
|
1293
1326
|
};
|
|
1327
|
+
const markdownRules = {
|
|
1328
|
+
printWidth: 120,
|
|
1329
|
+
...rules,
|
|
1330
|
+
embeddedLanguageFormatting: "off"
|
|
1331
|
+
};
|
|
1294
1332
|
if (plugins?.length) {
|
|
1295
1333
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1296
1334
|
}
|
|
@@ -1304,7 +1342,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1304
1342
|
prettier: pluginPrettier
|
|
1305
1343
|
},
|
|
1306
1344
|
rules: {
|
|
1307
|
-
"prettier/prettier": ["warn", rules]
|
|
1345
|
+
"prettier/prettier": ["warn", parser === "markdown" ? markdownRules : rules]
|
|
1308
1346
|
}
|
|
1309
1347
|
};
|
|
1310
1348
|
return config;
|
|
@@ -1547,7 +1585,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1547
1585
|
acc[key] = options[key];
|
|
1548
1586
|
return acc;
|
|
1549
1587
|
}, {});
|
|
1550
|
-
if (Object.keys(fusedConfig).length)
|
|
1588
|
+
if (Object.keys(fusedConfig).length > 0)
|
|
1551
1589
|
configs.push([fusedConfig]);
|
|
1552
1590
|
const merged = combine(...configs, ...userConfigs);
|
|
1553
1591
|
return merged;
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
|
7
7
|
var DEFAULT_PRETTIER_RULES = {
|
|
8
8
|
arrowParens: "avoid",
|
|
9
9
|
htmlWhitespaceSensitivity: "ignore",
|
|
10
|
-
printWidth:
|
|
10
|
+
printWidth: 80,
|
|
11
11
|
semi: false,
|
|
12
12
|
singleQuote: true
|
|
13
13
|
};
|
|
@@ -953,31 +953,64 @@ async function unicorn() {
|
|
|
953
953
|
},
|
|
954
954
|
rules: {
|
|
955
955
|
"unicorn/better-regex": "error",
|
|
956
|
-
|
|
956
|
+
"unicorn/catch-error-name": "error",
|
|
957
|
+
"unicorn/custom-error-definition": "error",
|
|
957
958
|
"unicorn/error-message": "error",
|
|
958
|
-
// Uppercase regex escapes
|
|
959
959
|
"unicorn/escape-case": "error",
|
|
960
|
-
|
|
960
|
+
"unicorn/explicit-length-check": "error",
|
|
961
|
+
// 'unicorn/filename-case': [
|
|
962
|
+
// 'error',
|
|
963
|
+
// {
|
|
964
|
+
// cases: { kebabCase: true, pascalCase: true },
|
|
965
|
+
// ignore: [/^[A-Z]+\..*$/],
|
|
966
|
+
// },
|
|
967
|
+
// ],
|
|
968
|
+
"unicorn/new-for-builtins": "error",
|
|
969
|
+
"unicorn/no-array-callback-reference": "error",
|
|
970
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
971
|
+
"unicorn/no-array-push-push": "error",
|
|
972
|
+
"unicorn/no-console-spaces": "error",
|
|
973
|
+
"unicorn/no-for-loop": "error",
|
|
974
|
+
"unicorn/no-hex-escape": "error",
|
|
961
975
|
"unicorn/no-instanceof-array": "error",
|
|
962
|
-
|
|
976
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
977
|
+
"unicorn/no-lonely-if": "error",
|
|
963
978
|
"unicorn/no-new-array": "error",
|
|
964
|
-
// Prevent deprecated `new Buffer()`
|
|
965
979
|
"unicorn/no-new-buffer": "error",
|
|
966
|
-
|
|
967
|
-
"unicorn/
|
|
968
|
-
|
|
980
|
+
"unicorn/no-static-only-class": "error",
|
|
981
|
+
"unicorn/no-unnecessary-await": "error",
|
|
982
|
+
"unicorn/no-zero-fractions": `error`,
|
|
983
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
984
|
+
"unicorn/prefer-array-find": "error",
|
|
985
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
986
|
+
"unicorn/prefer-array-index-of": "error",
|
|
987
|
+
"unicorn/prefer-array-some": "error",
|
|
988
|
+
"unicorn/prefer-at": "error",
|
|
989
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
990
|
+
"unicorn/prefer-date-now": "error",
|
|
991
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
992
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
993
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
969
994
|
"unicorn/prefer-dom-node-text-content": "error",
|
|
970
|
-
// includes over indexOf when checking for existence
|
|
971
995
|
"unicorn/prefer-includes": "error",
|
|
972
|
-
|
|
996
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
997
|
+
"unicorn/prefer-math-trunc": "error",
|
|
998
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
999
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
1000
|
+
"unicorn/prefer-negative-index": "error",
|
|
973
1001
|
"unicorn/prefer-node-protocol": "error",
|
|
974
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
975
1002
|
"unicorn/prefer-number-properties": "error",
|
|
976
|
-
|
|
1003
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
1004
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
1005
|
+
"unicorn/prefer-query-selector": "error",
|
|
1006
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
1007
|
+
"unicorn/prefer-regexp-test": "error",
|
|
1008
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
1009
|
+
"unicorn/prefer-string-slice": "error",
|
|
977
1010
|
"unicorn/prefer-string-starts-ends-with": "error",
|
|
978
|
-
|
|
1011
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
1012
|
+
"unicorn/prefer-top-level-await": "error",
|
|
979
1013
|
"unicorn/prefer-type-error": "error",
|
|
980
|
-
// Use new when throwing error
|
|
981
1014
|
"unicorn/throw-new-error": "error"
|
|
982
1015
|
}
|
|
983
1016
|
}
|
|
@@ -1257,6 +1290,11 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1257
1290
|
...prettierRules2,
|
|
1258
1291
|
parser
|
|
1259
1292
|
};
|
|
1293
|
+
const markdownRules = {
|
|
1294
|
+
printWidth: 120,
|
|
1295
|
+
...rules,
|
|
1296
|
+
embeddedLanguageFormatting: "off"
|
|
1297
|
+
};
|
|
1260
1298
|
if (plugins?.length) {
|
|
1261
1299
|
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
1262
1300
|
}
|
|
@@ -1270,7 +1308,7 @@ async function formatter(options = {}, prettierRules2 = {}) {
|
|
|
1270
1308
|
prettier: pluginPrettier
|
|
1271
1309
|
},
|
|
1272
1310
|
rules: {
|
|
1273
|
-
"prettier/prettier": ["warn", rules]
|
|
1311
|
+
"prettier/prettier": ["warn", parser === "markdown" ? markdownRules : rules]
|
|
1274
1312
|
}
|
|
1275
1313
|
};
|
|
1276
1314
|
return config;
|
|
@@ -1513,7 +1551,7 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1513
1551
|
acc[key] = options[key];
|
|
1514
1552
|
return acc;
|
|
1515
1553
|
}, {});
|
|
1516
|
-
if (Object.keys(fusedConfig).length)
|
|
1554
|
+
if (Object.keys(fusedConfig).length > 0)
|
|
1517
1555
|
configs.push([fusedConfig]);
|
|
1518
1556
|
const merged = combine(...configs, ...userConfigs);
|
|
1519
1557
|
return merged;
|
package/package.json
CHANGED