@dauphaihau/eslint-config 0.1.5 → 0.2.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.js +28 -18
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -216,7 +216,7 @@ function baseConfig(options = {}) {
|
|
|
216
216
|
plugins: { "@stylistic": stylistic },
|
|
217
217
|
rules: {
|
|
218
218
|
// Spacing
|
|
219
|
-
"@stylistic/
|
|
219
|
+
"@stylistic/function-call-spacing": "error",
|
|
220
220
|
"@stylistic/space-before-function-paren": ["error", {
|
|
221
221
|
anonymous: "always",
|
|
222
222
|
named: "never",
|
|
@@ -423,6 +423,17 @@ function typescriptConfig(options = {}) {
|
|
|
423
423
|
}
|
|
424
424
|
|
|
425
425
|
// src/configs/react.ts
|
|
426
|
+
import fs from "fs";
|
|
427
|
+
function getReactVersion() {
|
|
428
|
+
try {
|
|
429
|
+
const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
|
|
430
|
+
const dep = pkg.dependencies?.react || pkg.devDependencies?.react || pkg.peerDependencies?.react;
|
|
431
|
+
const match = dep?.match(/\d+/);
|
|
432
|
+
if (match) return `${match[0]}.0`;
|
|
433
|
+
} catch {
|
|
434
|
+
}
|
|
435
|
+
return "18.0";
|
|
436
|
+
}
|
|
426
437
|
async function reactConfig(options = {}) {
|
|
427
438
|
const reactFiles = strategyManager.getReactFiles(options);
|
|
428
439
|
if (reactFiles.length === 0) {
|
|
@@ -461,8 +472,7 @@ async function reactConfig(options = {}) {
|
|
|
461
472
|
},
|
|
462
473
|
settings: {
|
|
463
474
|
react: {
|
|
464
|
-
version:
|
|
465
|
-
// Automatically detect React version
|
|
475
|
+
version: getReactVersion()
|
|
466
476
|
}
|
|
467
477
|
},
|
|
468
478
|
rules: {
|
|
@@ -648,7 +658,7 @@ function namingConfig(options = {}) {
|
|
|
648
658
|
}
|
|
649
659
|
|
|
650
660
|
// src/configs/file-names.ts
|
|
651
|
-
import
|
|
661
|
+
import checkFile from "eslint-plugin-check-file";
|
|
652
662
|
function fileNamesConfig(options = {}) {
|
|
653
663
|
const allFiles = strategyManager.getSourceFiles(options);
|
|
654
664
|
const tsxFiles = strategyManager.getComponentFiles(options);
|
|
@@ -657,15 +667,15 @@ function fileNamesConfig(options = {}) {
|
|
|
657
667
|
name: "dauphaihau/file-names",
|
|
658
668
|
files: allFiles,
|
|
659
669
|
plugins: {
|
|
660
|
-
"
|
|
670
|
+
"check-file": checkFile
|
|
661
671
|
},
|
|
662
672
|
rules: {
|
|
663
673
|
// Enforce kebab-case for regular files
|
|
664
|
-
"
|
|
674
|
+
"check-file/filename-naming-convention": [
|
|
665
675
|
"error",
|
|
666
|
-
{
|
|
667
|
-
|
|
668
|
-
|
|
676
|
+
{ "**/*": "KEBAB_CASE" },
|
|
677
|
+
{ ignoreMiddleExtensions: true }
|
|
678
|
+
]
|
|
669
679
|
}
|
|
670
680
|
},
|
|
671
681
|
// TSX/JSX files: Allow PascalCase for React components (e.g., MyComponent.tsx)
|
|
@@ -673,14 +683,14 @@ function fileNamesConfig(options = {}) {
|
|
|
673
683
|
name: "dauphaihau/file-names-tsx",
|
|
674
684
|
files: tsxFiles,
|
|
675
685
|
plugins: {
|
|
676
|
-
"
|
|
686
|
+
"check-file": checkFile
|
|
677
687
|
},
|
|
678
688
|
rules: {
|
|
679
|
-
"
|
|
689
|
+
"check-file/filename-naming-convention": [
|
|
680
690
|
"error",
|
|
681
|
-
{
|
|
682
|
-
|
|
683
|
-
|
|
691
|
+
{ "**/*": "PASCAL_CASE" },
|
|
692
|
+
{ ignoreMiddleExtensions: true }
|
|
693
|
+
]
|
|
684
694
|
}
|
|
685
695
|
}
|
|
686
696
|
];
|
|
@@ -861,13 +871,13 @@ var ESLintConfigBuilder = class {
|
|
|
861
871
|
};
|
|
862
872
|
|
|
863
873
|
// src/index.ts
|
|
864
|
-
import
|
|
865
|
-
var hasTsConfig =
|
|
874
|
+
import fs2 from "fs";
|
|
875
|
+
var hasTsConfig = fs2.existsSync("tsconfig.json") || fs2.existsSync("tsconfig.base.json");
|
|
866
876
|
var hasReact = () => {
|
|
867
877
|
try {
|
|
868
878
|
const packageJsonPath = "package.json";
|
|
869
|
-
if (
|
|
870
|
-
const packageJson = JSON.parse(
|
|
879
|
+
if (fs2.existsSync(packageJsonPath)) {
|
|
880
|
+
const packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
871
881
|
const deps = {
|
|
872
882
|
...packageJson.dependencies,
|
|
873
883
|
...packageJson.devDependencies,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dauphaihau/eslint-config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,14 +12,14 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@eslint/js": "^
|
|
16
|
-
"@stylistic/eslint-plugin": "^
|
|
17
|
-
"eslint-plugin-
|
|
15
|
+
"@eslint/js": "^10.0.0",
|
|
16
|
+
"@stylistic/eslint-plugin": "^5.9.0",
|
|
17
|
+
"eslint-plugin-check-file": "^3.3.1",
|
|
18
18
|
"globals": "^16.5.0",
|
|
19
|
-
"typescript-eslint": "^8.
|
|
19
|
+
"typescript-eslint": "^8.56.1"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"eslint": "^9.0.0"
|
|
22
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependenciesMeta": {
|
|
25
25
|
"eslint-plugin-react": {
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^22.0.0",
|
|
37
|
-
"eslint": "^
|
|
38
|
-
"eslint-plugin-react": "^7.
|
|
39
|
-
"eslint-plugin-react-hooks": "^
|
|
40
|
-
"eslint-plugin-react-refresh": "^0.
|
|
37
|
+
"eslint": "^10.0.0",
|
|
38
|
+
"eslint-plugin-react": "^7.37.5",
|
|
39
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
40
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
41
41
|
"jiti": "^2.0.0",
|
|
42
42
|
"tsup": "^8.0.0",
|
|
43
43
|
"typescript": "^5.4.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
|
-
"build": "pnpm exec tsup src/index.ts --dts --format esm --external @eslint/js --external @stylistic/eslint-plugin --external typescript-eslint --external eslint-plugin-
|
|
46
|
+
"build": "pnpm exec tsup src/index.ts --dts --format esm --external @eslint/js --external @stylistic/eslint-plugin --external typescript-eslint --external eslint-plugin-check-file --external eslint-plugin-react --external eslint-plugin-react-hooks --external eslint-plugin-react-refresh",
|
|
47
47
|
"lint": "eslint .",
|
|
48
48
|
"lint:fix": "eslint . --fix",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|