@jeportie/create-checks 1.0.0 → 1.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jeportie/create-checks",
3
- "version": "1.0.0",
3
+ "version": "1.3.1",
4
4
  "description": "Scaffolding CLI that installs ESLint + Prettier and injects config into any project",
5
5
  "author": "jeportie",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -8,9 +8,21 @@ import { fileURLToPath } from 'node:url';
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
10
  const cwd = process.cwd();
11
+ const pkgPath = path.join(cwd, 'package.json');
11
12
 
12
13
  console.log(pc.cyan('\nšŸ”§ create-checks — setting up ESLint + Prettier\n'));
13
14
 
15
+ /* ---------------- ENSURE package.json EXISTS ---------------- */
16
+
17
+ if (!(await fs.pathExists(pkgPath))) {
18
+ console.log(pc.yellow(' No package.json found — running npm init -y...'));
19
+ await execa('npm', ['init', '-y'], { stdio: 'inherit' });
20
+ const pkg = await fs.readJson(pkgPath);
21
+ pkg.type = 'module';
22
+ await fs.writeJson(pkgPath, pkg, { spaces: 2 });
23
+ console.log(pc.green(' āœ”') + ' package.json created with "type": "module"');
24
+ }
25
+
14
26
  /* ---------------- INSTALL DEPENDENCIES ---------------- */
15
27
 
16
28
  if (!process.env.NO_INSTALL) {
@@ -20,13 +32,17 @@ if (!process.env.NO_INSTALL) {
20
32
  [
21
33
  'install',
22
34
  '-D',
23
- 'eslint',
35
+
36
+ 'eslint@^9',
24
37
  'prettier',
25
- 'eslint-config-prettier',
38
+ 'eslint-config-prettier@^9.1.0',
39
+ '@eslint/js',
26
40
  'typescript-eslint',
27
41
  '@stylistic/eslint-plugin',
28
42
  'eslint-plugin-import',
29
43
  'eslint-import-resolver-typescript',
44
+ 'typescript',
45
+ '@types/node',
30
46
  ],
31
47
  { stdio: 'inherit' },
32
48
  );
@@ -47,9 +63,22 @@ if (!(await fs.pathExists(path.join(cwd, '.editorconfig')))) {
47
63
  console.log(pc.dim(' –') + ' .editorconfig (already exists, skipped)');
48
64
  }
49
65
 
66
+ if (!(await fs.pathExists(path.join(cwd, 'tsconfig.base.json')))) {
67
+ await fs.copyFile(path.join(__dirname, 'templates/tsconfig.base.json'), path.join(cwd, 'tsconfig.base.json'));
68
+ console.log(pc.green(' āœ”') + ' tsconfig.base.json');
69
+ } else {
70
+ console.log(pc.dim(' –') + ' tsconfig.base.json (already exists, skipped)');
71
+ }
72
+
73
+ if (!(await fs.pathExists(path.join(cwd, 'tsconfig.json')))) {
74
+ await fs.copyFile(path.join(__dirname, 'templates/tsconfig.json'), path.join(cwd, 'tsconfig.json'));
75
+ console.log(pc.green(' āœ”') + ' tsconfig.json');
76
+ } else {
77
+ console.log(pc.dim(' –') + ' tsconfig.json (already exists, skipped)');
78
+ }
79
+
50
80
  /* ---------------- UPDATE package.json ---------------- */
51
81
 
52
- const pkgPath = path.join(cwd, 'package.json');
53
82
  const pkg = await fs.readJson(pkgPath);
54
83
 
55
84
  pkg.scripts = {
@@ -4,7 +4,8 @@ import prettier from 'eslint-config-prettier';
4
4
  import importPlugin from 'eslint-plugin-import';
5
5
  import tseslint from 'typescript-eslint';
6
6
 
7
- export default tseslint.config([
7
+ export default tseslint.config(
8
+ /* ---------------- GLOBAL IGNORES ---------------- */
8
9
  {
9
10
  ignores: [
10
11
  '**/dist/**',
@@ -14,25 +15,26 @@ export default tseslint.config([
14
15
  ],
15
16
  },
16
17
 
18
+ /* ---------------- BASE CONFIGS ---------------- */
17
19
  eslint.configs.recommended,
20
+ ...tseslint.configs.recommendedTypeChecked,
21
+ ...tseslint.configs.stylisticTypeChecked,
18
22
 
19
- tseslint.configs.recommendedTypeChecked,
20
- tseslint.configs.stylisticTypeChecked,
21
-
23
+ /* ---------------- TYPESCRIPT PARSER OPTIONS ---------------- */
22
24
  {
23
- plugins: {
24
- '@stylistic': stylistic,
25
- import: importPlugin,
26
- },
27
-
28
25
  languageOptions: {
29
26
  parserOptions: {
30
- projectService: {
31
- allowDefaultProject: ['*.ts'],
32
- },
27
+ projectService: true,
33
28
  tsconfigRootDir: import.meta.dirname,
34
29
  },
35
30
  },
31
+ },
32
+
33
+ /* ---------------- IMPORT PLUGIN ---------------- */
34
+ {
35
+ plugins: {
36
+ import: importPlugin,
37
+ },
36
38
 
37
39
  settings: {
38
40
  'import/resolver': {
@@ -42,7 +44,6 @@ export default tseslint.config([
42
44
  },
43
45
 
44
46
  rules: {
45
- /* ---------------- IMPORTS ---------------- */
46
47
  'import/first': 'error',
47
48
  'import/no-cycle': 'error',
48
49
  'import/no-self-import': 'error',
@@ -63,12 +64,29 @@ export default tseslint.config([
63
64
  'newlines-between': 'always',
64
65
  },
65
66
  ],
67
+ },
68
+ },
66
69
 
67
- /* ---------------- STYLISTIC ---------------- */
70
+ /* ---------------- STYLISTIC RULES ---------------- */
71
+ {
72
+ plugins: {
73
+ '@stylistic': stylistic,
74
+ },
75
+
76
+ rules: {
68
77
  '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
69
- 'spaced-comment': ['error', 'always'],
78
+ },
79
+ },
70
80
 
71
- /* ---------------- TYPESCRIPT ---------------- */
81
+ /* ---------------- GENERAL RULES ---------------- */
82
+ {
83
+ rules: {
84
+ 'sort-imports': 'off',
85
+ 'spaced-comment': [
86
+ 'error',
87
+ 'always',
88
+ { block: { markers: ['!'], balanced: true } },
89
+ ],
72
90
  '@typescript-eslint/no-unused-vars': [
73
91
  'error',
74
92
  { argsIgnorePattern: '^_' },
@@ -78,20 +96,25 @@ export default tseslint.config([
78
96
 
79
97
  /* ---------------- TEST OVERRIDES ---------------- */
80
98
  {
81
- files: ['**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
99
+ files: [
100
+ '**/__tests__/**/*.{ts,tsx}',
101
+ '**/*.test.{ts,tsx}',
102
+ '**/*.spec.{ts,tsx}',
103
+ ],
82
104
  rules: {
83
105
  '@typescript-eslint/no-explicit-any': 'off',
84
106
  '@typescript-eslint/no-unsafe-assignment': 'off',
107
+ '@typescript-eslint/no-unsafe-member-access': 'off',
85
108
  '@typescript-eslint/no-unsafe-call': 'off',
86
109
  },
87
110
  },
88
111
 
89
112
  /* ---------------- CONFIG FILES ---------------- */
90
113
  {
91
- files: ['*.config.{js,mjs,cjs}'],
114
+ files: ['*.config.{js,mjs,cjs}', '**/*.config.{js,mjs,cjs}'],
92
115
  ...tseslint.configs.disableTypeChecked,
93
116
  },
94
117
 
95
118
  /* ---------------- PRETTIER MUST BE LAST ---------------- */
96
119
  prettier,
97
- ]);
120
+ );
@@ -0,0 +1,33 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2022",
4
+ "lib": ["es2023"],
5
+ "module": "NodeNext",
6
+ "moduleResolution": "NodeNext",
7
+ "resolveJsonModule": true,
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "removeComments": true,
12
+ "isolatedModules": true,
13
+ "allowSyntheticDefaultImports": true,
14
+ "esModuleInterop": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "strict": true,
17
+ "alwaysStrict": true,
18
+ "noImplicitAny": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "exactOptionalPropertyTypes": true,
22
+ "noImplicitReturns": true,
23
+ "noFallthroughCasesInSwitch": true,
24
+ "noUncheckedIndexedAccess": true,
25
+ "noImplicitOverride": true,
26
+ "allowUnusedLabels": false,
27
+ "allowUnreachableCode": false,
28
+ "skipLibCheck": true,
29
+ "verbatimModuleSyntax": true,
30
+ "noErrorTruncation": true,
31
+ "useUnknownInCatchVariables": false
32
+ }
33
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "noEmit": true,
5
+ "baseUrl": ".",
6
+ "paths": {
7
+ "@/*": ["src/*"]
8
+ },
9
+ "types": ["node"]
10
+ },
11
+ "include": ["src", "./*.ts", "./*.js", "./*.mjs", "./*.cjs"],
12
+ "exclude": ["node_modules"]
13
+ }