@petbee/eslint-config 1.0.8 → 1.0.9

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.
Files changed (2) hide show
  1. package/README.md +61 -14
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,37 +1,84 @@
1
- # `@petbee/prettier-config`
1
+ # `@petbee/eslint-config`
2
2
 
3
- This package provides Petbees's `.prettierrc` shared config.
3
+ This package provides Petbee's `.eslintrc` as an extensible shared config.
4
4
 
5
5
  ## Installation
6
6
 
7
- Give that you already have `prettier` installed, run:
7
+ Give that you already have ESLint installed, run:
8
8
 
9
9
  ```bash
10
- yarn add -D @petbee/prettier-config
10
+ yarn add -D @petbee/eslint-config typescript prettier
11
11
  ```
12
12
 
13
13
  ## Usage
14
14
 
15
- After installing the module, add it to your `.prettierrc` configuration file:
15
+ After installing the module, just add it to your `extends` array inside your `.eslintrc`.
16
16
 
17
17
  ```jsonc
18
- "@petbee/prettier-config"
18
+ // .eslintrc
19
+ {
20
+ "extends": ["@petbee/eslint-config"]
21
+ }
19
22
  ```
20
23
 
21
- Or add it to your `package.json`:
24
+ As any other eslint preset, it's possible to override some rules and configurations. We encourage trying to keep the closest possible to the preset rules, but every project is different and sometimes overriding is needed, use it carefully.
25
+
26
+ ### For typescript
22
27
 
23
- ```json
28
+ The preset will automatically load Typescript rules when dealing with `.ts` or `.tsx` files. However, there are some rules that require type-checking. This means that a `tsconfig.json`, which includes all files supposed to be linted, must be present. If your existing configuration does not include all of the files you would like to lint, you can create a separate `tsconfig.eslint.json`, at the root of your project, as follows:
29
+
30
+ ```jsonc
31
+ // tsconfig.eslint.json
24
32
  {
25
- ...
26
- "prettier": "@petbee/prettier-config"
27
- ...
33
+ "extends": "./tsconfig.json",
34
+ "include": ["**/*.ts", "**/*.tsx", "**/*.js"],
35
+ "exclude": []
28
36
  }
29
37
  ```
30
38
 
31
- Differently from `eslint`, `prettier` shared presets are not extensible, so if you want to override some property, which is not encouraged, you'll need to use the `.prettierrc.js` file.
39
+ And you should be good to go.
40
+
41
+ ### For Javascript
42
+
43
+ Sometimes you want to use modern, not yet officially supported, syntax in your Javascript files, such as dynamic `import()`. This can be achieved by using the [`babel-eslint` parser](https://github.com/babel/babel-eslint). For size reasons, we don't include it in this preset but it's extremely simple to configure it:
44
+
45
+ ```bash
46
+ yarn add -D babel-eslint
47
+ ```
48
+
49
+ ```jsonc
50
+ // .eslintrc
51
+ {
52
+ "extends": "@petbee/eslint-config",
53
+ "parser": "babel-eslint",
54
+ "parserOptions": {
55
+ "sourceType": "module"
56
+ }
57
+ }
58
+ ```
59
+
60
+ If a project uses both Typescript and Javascript, you can configure the parser inside an `override` block:
61
+
62
+ ```jsonc
63
+ // .eslintrc
64
+ {
65
+ "extends": "@petbee/eslint-config",
66
+ "overrides": [
67
+ {
68
+ "files": ["*.js", "*.jsx"],
69
+ "parser": "babel-eslint",
70
+ "parserOptions": {
71
+ "sourceType": "module"
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ ```
32
77
 
33
- For more information about configuring `prettier`, please check the [Prettier configuration documentation](https://prettier.io/docs/en/configuration.html).
78
+ Please check the [`babel-eslint` documentation](https://github.com/babel/babel-eslint#additional-parser-configuration) for further options.
34
79
 
35
80
  ## References
36
81
 
37
- - [`prettier` options documentation](https://prettier.io/docs/en/options.html)
82
+ - [`@typescript-eslint` documentation](https://typescript-eslint.io/docs/)
83
+ - [`eslint-plugin-import` documentation](https://github.com/benmosher/eslint-plugin-import)
84
+ - [`eslint-plugin-prettier` documentation](https://github.com/prettier/eslint-plugin-prettier)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@petbee/eslint-config",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "Petbee's eslint config",
5
5
  "keywords": [
6
6
  "eslint",
@@ -54,7 +54,7 @@
54
54
  "typescript": "^4.0.0 || ^5.0.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@petbee/prettier-config": "^1.0.2",
57
+ "@petbee/prettier-config": "^1.0.3",
58
58
  "@types/react": "18.2.37",
59
59
  "eslint": "8.53.0",
60
60
  "prettier": "3.0.3",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "c82ef9eb64c9c3383f93fa757f38efb579f3aa37"
67
+ "gitHead": "4abb4d54bdc927736aee06803e0e9a5d179acfa1"
68
68
  }