eureka-init 1.0.6 โ†’ 1.1.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/README.md CHANGED
@@ -8,6 +8,20 @@ Modul untuk menyeragamkan format commit, linting, dan formatting di seluruh proj
8
8
  - Memudahkan tracking bug & fitur.
9
9
  - Siap untuk CI/CD dan audit sistem.
10
10
 
11
+ ## ๐Ÿ“ข Rangkuman Update Terbaru (v1.0.6 - v1.1.0)
12
+
13
+ Modul ini telah mendapatkan peningkatan signifikan untuk mendukung ekosistem pengembangan modern (khususnya React dan Next.js) secara *out-of-the-box*:
14
+
15
+ ### ๐ŸŒŸ v1.1.0: Integrasi `lint-staged` & Linter React
16
+ - **`lint-staged` & Hook Pre-commit Super Cepat**: Hook `pre-commit` kini otomatis menjalankan `npx lint-staged`. Proses linting dan formatting hanya dilakukan pada file yang mengalami perubahan (di-stage), bukan keseluruhan project, sehingga *commit* menjadi jauh lebih cepat.
17
+ - **Optimasi Tanpa Redundansi**: Konfigurasi `lint-staged.config.js` dirancang cerdas untuk menghindari kerja dua kali. Eksekusi `eslint --fix` pada file JS/TS/JSX/TSX sudah otomatis mencakup *formatting* Prettier (melalui `plugin:prettier/recommended`), sedangkan file non-JS (`.json, .css, .md`) tetap dirapikan dengan `prettier --write`.
18
+ - **Dukungan Penuh Aturan React**: Konfigurasi ESLint (`.eslintrc.js`) kini sudah terbundel dengan `eslint-plugin-react` (`plugin:react/recommended`). Aturan usang pada React modern seperti `react-in-jsx-scope` dan `prop-types` telah dinonaktifkan secara otomatis.
19
+
20
+ ### ๐Ÿงช v1.0.6: Standarisasi Unit Testing dengan Jest
21
+ - **Environment Testing Siap Pakai**: Konfigurasi `jest.config.js` dan `jest.setup.js` telah disesuaikan untuk pengujian komponen UI React/Next.js menggunakan `@testing-library/react`, `@testing-library/jest-dom`, `@testing-library/user-event`, dan `jest-environment-jsdom`.
22
+ - **Mocking & Modul Alias**: Sudah dilengkapi konfigurasi penanganan aset statis serta pemetaan CSS Modules (`identity-obj-proxy`) agar test tidak gagal saat mengimpor file styling.
23
+ - **Contoh Test Otomatis**: Saat inisialisasi (`npx eureka-init`), sistem otomatis membuat struktur folder `src/__tests__` beserta file `example.test.js` sebagai acuan dan panduan standar penulisan test bagi tim developer.
24
+
11
25
  ## ๐Ÿš€ Cara Penggunaan
12
26
 
13
27
  ### 1. Install Dependency
@@ -27,11 +41,12 @@ npx eureka-init
27
41
  Perintah ini akan:
28
42
  1. Membuat file `commitlint.config.js`.
29
43
  2. Membuat file `.prettierrc`.
30
- 3. Membuat file `.eslintrc.js`.
31
- 4. Membuat file `jest.config.js` dan `jest.setup.js`.
32
- 5. Menjalankan `npx husky install`.
33
- 6. Membuat hook `.husky/commit-msg` dan `.husky/pre-commit`.
34
- 7. Menambahkan script `prepare`, `lint`, `format`, dan `test` di `package.json`.
44
+ 3. Membuat file `.eslintrc.js` (dilengkapi dengan `eslint-plugin-react`).
45
+ 4. Membuat file `lint-staged.config.js`.
46
+ 5. Membuat file `jest.config.js` dan `jest.setup.js`.
47
+ 6. Menjalankan `npx husky install`.
48
+ 7. Membuat hook `.husky/commit-msg` dan `.husky/pre-commit` (terintegrasi dengan `lint-staged`).
49
+ 8. Menambahkan script `prepare`, `lint`, `format`, `test`, dan `lint-staged` di `package.json`.
35
50
 
36
51
  ## ๐Ÿงฑ Format Commit
37
52
  Gunakan format: `<type>: <subject>`
@@ -55,3 +70,4 @@ Setelah instalasi, Anda bisa menggunakan:
55
70
  - `npm run lint`: Menjalankan eslint.
56
71
  - `npm run format`: Menjalankan prettier untuk merapikan kode.
57
72
  - `npm run test`: Menjalankan unit test menggunakan Jest.
73
+ - `npm run lint-staged`: Menjalankan linting dan formatting otomatis pada file yang di-stage sebelum commit.
@@ -29,6 +29,10 @@ function setup() {
29
29
  path.join(templateDir, '.eslintrc.js'),
30
30
  path.join(cwd, '.eslintrc.js')
31
31
  );
32
+ copyFile(
33
+ path.join(templateDir, 'lint-staged.config.js'),
34
+ path.join(cwd, 'lint-staged.config.js')
35
+ );
32
36
  copyFile(
33
37
  path.join(templateDir, 'jest.config.js'),
34
38
  path.join(cwd, 'jest.config.js')
@@ -97,6 +101,9 @@ function setup() {
97
101
  if (!pkg.scripts.test) {
98
102
  pkg.scripts.test = 'jest --passWithNoTests';
99
103
  }
104
+ if (!pkg.scripts['lint-staged']) {
105
+ pkg.scripts['lint-staged'] = 'lint-staged';
106
+ }
100
107
 
101
108
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
102
109
  console.log('โœ… Updated package.json scripts');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eureka-init",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "description": "Shared configuration for Husky, Commitlint, Prettier, ESLint, and Jest for Eureka Group",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -16,7 +16,9 @@
16
16
  "husky",
17
17
  "commitlint",
18
18
  "prettier",
19
- "eureka"
19
+ "eureka",
20
+ "lint-staged",
21
+ "eslint-plugin-react"
20
22
  ],
21
23
  "author": "Eureka Group",
22
24
  "license": "ISC",
@@ -29,10 +31,12 @@
29
31
  "eslint": "^8.57.0",
30
32
  "eslint-config-prettier": "^9.1.0",
31
33
  "eslint-plugin-prettier": "^5.1.3",
34
+ "eslint-plugin-react": "^7.34.1",
32
35
  "husky": "^9.0.11",
36
+ "identity-obj-proxy": "^3.0.0",
33
37
  "jest": "^29.7.0",
34
38
  "jest-environment-jsdom": "^29.7.0",
35
- "identity-obj-proxy": "^3.0.0",
39
+ "lint-staged": "^15.2.2",
36
40
  "prettier": "^3.2.5"
37
41
  }
38
42
  }
@@ -6,14 +6,23 @@ module.exports = {
6
6
  },
7
7
  extends: [
8
8
  'eslint:recommended',
9
+ 'plugin:react/recommended',
9
10
  'plugin:prettier/recommended',
10
11
  ],
12
+ plugins: ['react'],
11
13
  parserOptions: {
12
14
  ecmaVersion: 'latest',
13
15
  sourceType: 'module',
14
16
  },
17
+ settings: {
18
+ react: {
19
+ version: 'detect',
20
+ },
21
+ },
15
22
  rules: {
16
23
  'no-console': 'warn',
17
24
  'prettier/prettier': 'error',
25
+ 'react/react-in-jsx-scope': 'off',
26
+ 'react/prop-types': 'off',
18
27
  },
19
28
  };
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
- npm run lint
4
+ npx lint-staged
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ // eslint --fix sudah otomatis menjalankan Prettier sekaligus memperbaiki linter
3
+ '*.{js,jsx,ts,tsx}': ['eslint --fix'],
4
+ // File non-JS/TS tetap menggunakan prettier secara langsung
5
+ '*.{json,css,scss,md}': ['prettier --write'],
6
+ };