@madgex/eslint-config-madgex 2.2.0 → 2.3.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.
Files changed (3) hide show
  1. package/README.md +33 -8
  2. package/index.js +8 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -10,28 +10,36 @@ npm install eslint@9 @madgex/eslint-config-madgex -save-dev
10
10
 
11
11
  ## VSCode extension
12
12
 
13
- Use VSCode Extension v3.0.5+ (you might need to switch to pre-release version)
13
+ Use the official VSCode [ESLint Extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) v3.0.5+ (you might need to switch to pre-release version)
14
14
 
15
15
  ## Usage
16
16
 
17
17
  > ⚠️ Recomended to use only 1 type of source file in your repo, either `commonjs` or `module` (esm). `eslint` & `eslint-plugin-n` (this config depends on) has difficulty supporting both at the same time in a monorepo.
18
18
 
19
- ```json
19
+ `eslint-plugin-n` which is a part of our config, reads the package.json for node version, and what `type` of JS files you use (ESM or commonjs).
20
+
21
+ ```json5
20
22
  // package.json
21
- // ESM import/export modules, set to commonjs if you are using `require/module.exports`, you cant use both
22
- "type": "module",
23
23
  {
24
- "engines": {
25
- "node": ">=18"
26
- }
24
+ ...
25
+ "type": "module", // "module" (ESM), or "commonjs" - you cant use both
26
+ {
27
+ "engines": {
28
+ "node": ">=18"
29
+ }
30
+ },
31
+ ...
27
32
  }
28
33
  ```
29
34
 
35
+ `eslint-plugin-n` also recognises `.npmignore` files which will silence warnings of missing dependancies when they are installed as `devDependancies`.
36
+
30
37
  ### Node/Browser
31
38
 
32
39
  ```js
33
40
  // eslint.config.js
34
41
  import configMadgex from '@madgex/eslint-config-madgex';
42
+
35
43
  export default [...configMadgex];
36
44
  ```
37
45
 
@@ -43,6 +51,23 @@ config order matters.
43
51
  // eslint.config.js
44
52
  import configMadgex from '@madgex/eslint-config-madgex';
45
53
  import pluginVue from 'eslint-plugin-vue';
54
+ // pluginVue.configs['flat/recommended'] has prettier conflicts
46
55
 
47
- export default [...configMadgex, ...pluginVue.configs['flat/recommended']];
56
+ export default [...configMadgex, ...pluginVue.configs['flat/essential']];
48
57
  ```
58
+
59
+ ### Rules
60
+
61
+ Notes regarding specific rules enforced in this config:
62
+
63
+ - [`no-param-reassign`](https://eslint.org/docs/latest/rules/no-param-reassign) - Disallow reassigning function parameters, except for **`accu`** which is the accumulator in a `.reduce()` e.g.
64
+
65
+ ```js
66
+ Array.reduce((accu, key) => {
67
+ accu[key] = getVal(key);
68
+
69
+ return accu;
70
+ }, {});
71
+ ```
72
+
73
+ - [`no-unused-vars`](https://eslint.org/docs/latest/rules/no-unused-vars) - Disallow unused variables, except for `request` and `h` as found on hapi.js route handlers.
package/index.js CHANGED
@@ -37,7 +37,6 @@ module.exports = [
37
37
  // https://eslint.org/docs/latest/rules/
38
38
  'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
39
39
  'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
40
- 'no-param-reassign': ['error', { props: true }],
41
40
  eqeqeq: ['error', 'always', { null: 'ignore' }],
42
41
  'no-shadow': 'error',
43
42
  'no-lonely-if': 'error',
@@ -46,6 +45,14 @@ module.exports = [
46
45
  'default-case': 'error',
47
46
  'consistent-return': 'error',
48
47
  'func-names': 'warn',
48
+ 'no-param-reassign': [
49
+ 'error',
50
+ {
51
+ props: true,
52
+ ignorePropertyModificationsFor: ['accu'],
53
+ },
54
+ ],
55
+ 'no-unused-vars': ['error', { argsIgnorePattern: 'request|h' }],
49
56
  },
50
57
  },
51
58
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@madgex/eslint-config-madgex",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "type": "commonjs",
5
5
  "description": "Madgex ESLint config - based on eslint-config-airbnb",
6
6
  "main": "index.js",