eslint-config-dicodingacademy 0.9.2 → 0.9.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/.github/workflows/publish.yml +14 -0
- package/README.md +79 -2
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
@@ -8,9 +8,86 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
-
## ESLint
|
11
|
+
## ESLint Sharable Config
|
12
12
|
|
13
|
-
|
13
|
+
Kami menyediakan ESlint *[sharable config](https://eslint.org/docs/latest/extend/shareable-configs)* yang bisa digunakan untuk menerapkan style guide yang didefinisikan di sini.
|
14
|
+
|
15
|
+
### Using Sharable Config in ESLint 9 or Latest
|
16
|
+
|
17
|
+
Pasang package ESLint dan `eslint-config-dicodingacademy` dengan menggunakan perintah di bawah ini.
|
18
|
+
|
19
|
+
```shell
|
20
|
+
npm install --save-dev eslint eslint-config-dicodingacademy
|
21
|
+
```
|
22
|
+
|
23
|
+
Buatlah berkas [konfigurasi ESLint](https://eslint.org/docs/latest/use/configure/#extending-configuration-files) (contoh: `eslint.config.mjs`) dan di dalamnya tulis kode di bawah ini.
|
24
|
+
|
25
|
+
```javascript
|
26
|
+
import daStyle from 'eslint-config-dicodingacademy';
|
27
|
+
|
28
|
+
export default [
|
29
|
+
daStyle,
|
30
|
+
// other config style
|
31
|
+
];
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
Anda bisa mendeteksi kesalahan penulisan JavaScript melalui perintah di bawah ini.
|
36
|
+
|
37
|
+
```shell
|
38
|
+
npx eslint
|
39
|
+
```
|
40
|
+
|
41
|
+
Jika ada kode yang tidak sesuai dengan aturan, ESLint akan menampilkan informasinya pada STDOUT.
|
42
|
+
|
43
|
+
```text
|
44
|
+
/home/dimas/eslint-test/index.js
|
45
|
+
1:22 error Missing semicolon semi
|
46
|
+
|
47
|
+
✖ 1 problem (1 error, 0 warnings)
|
48
|
+
1 error and 0 warnings potentially fixable with the `--fix` option.
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
### Using Sharable Config in ESLint < 9
|
55
|
+
|
56
|
+
Pasang package ESLint (versi di bawah 9) dan `eslint-config-dicodingacademy` dengan menggunakan perintah di bawah ini.
|
57
|
+
|
58
|
+
```shell
|
59
|
+
npm install --save-dev eslint@8 eslint-config-dicodingacademy
|
60
|
+
```
|
61
|
+
|
62
|
+
Buatlah berkas [konfigurasi ESLint](https://eslint.org/docs/v8.x/use/configure/) (contoh: `.eslintrc.js`) dan di dalamnya tulis kode di bawah ini.
|
63
|
+
|
64
|
+
```javascript
|
65
|
+
module.exports = {
|
66
|
+
extends: ['dicodingacademy'],
|
67
|
+
parserOptions: {
|
68
|
+
ecmaVersion: 'latest'
|
69
|
+
}
|
70
|
+
// other config
|
71
|
+
};
|
72
|
+
|
73
|
+
```
|
74
|
+
|
75
|
+
Anda bisa mendeteksi kesalahan penulisan JavaScript melalui perintah di bawah ini.
|
76
|
+
|
77
|
+
```shell
|
78
|
+
npx eslint
|
79
|
+
```
|
80
|
+
|
81
|
+
Jika ada kode yang tidak sesuai dengan aturan, ESLint akan menampilkan informasinya pada STDOUT.
|
82
|
+
|
83
|
+
```text
|
84
|
+
/home/dimas/eslint-test/index.js
|
85
|
+
1:22 error Missing semicolon semi
|
86
|
+
|
87
|
+
✖ 1 problem (1 error, 0 warnings)
|
88
|
+
1 error and 0 warnings potentially fixable with the `--fix` option.
|
89
|
+
|
90
|
+
```
|
14
91
|
|
15
92
|
|
16
93
|
|
package/index.js
CHANGED
@@ -9,7 +9,7 @@ const plugin = {
|
|
9
9
|
'object-curly-spacing': ['error', 'always'],
|
10
10
|
'array-bracket-spacing': ['error', 'never'],
|
11
11
|
'space-in-parens': ['error', 'never'],
|
12
|
-
'space-before-function-paren': ['error', 'never'],
|
12
|
+
'space-before-function-paren': ['error', {'anonymous': 'always', 'named': 'never', 'asyncArrow': 'always'}],
|
13
13
|
'func-call-spacing': ['error', 'never'],
|
14
14
|
'keyword-spacing': ['error', {'before': true, 'after': true}],
|
15
15
|
'prefer-const': 'error',
|