@allthings/eslint-config 3.7.1-alpha.1 → 3.8.0-alpha.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.
Files changed (3) hide show
  1. package/README.md +20 -0
  2. package/functional.js +34 -0
  3. package/package.json +4 -1
package/README.md CHANGED
@@ -48,6 +48,26 @@ export default [
48
48
  ]
49
49
  ```
50
50
 
51
+ ### Functional-style Node.js projects
52
+
53
+ Opt-in strict-functional variant of the Node config. On top of everything in `/node`, it forbids `let`, classes, `this`, and all object/array mutation via [`eslint-plugin-functional`](https://github.com/eslint-functional/eslint-plugin-functional), and re-enables `unicorn/no-array-reverse` + `unicorn/no-array-sort` for consistency. Existing codebases will see a lot of errors on first run — this is intentional and aligns with the functional-programming style.
54
+
55
+ ```js
56
+ import allthingsFunctionalConfig from '@allthings/eslint-config/functional'
57
+
58
+ export default [
59
+ ...allthingsFunctionalConfig,
60
+ {
61
+ languageOptions: {
62
+ parserOptions: {
63
+ project: './tsconfig.json',
64
+ tsconfigRootDir: import.meta.dirname,
65
+ },
66
+ },
67
+ },
68
+ ]
69
+ ```
70
+
51
71
  ## Development
52
72
 
53
73
  Run `yarn link` in the project folder
package/functional.js ADDED
@@ -0,0 +1,34 @@
1
+ import functionalPlugin from 'eslint-plugin-functional'
2
+
3
+ import nodeConfig from './node.js'
4
+
5
+ const config = [
6
+ ...nodeConfig,
7
+ {
8
+ plugins: { functional: functionalPlugin },
9
+ rules: {
10
+ 'functional/immutable-data': 'error',
11
+ 'functional/no-classes': 'error',
12
+ 'functional/no-let': 'error',
13
+ 'functional/no-this-expressions': 'error',
14
+ // base.js turns these off citing perf/semantics of in-place mutation;
15
+ // in a functional codebase the same reasoning that bans property
16
+ // mutation bans .reverse() / .sort() too — they mutate in place.
17
+ 'unicorn/no-array-reverse': 'error',
18
+ 'unicorn/no-array-sort': 'error',
19
+ },
20
+ },
21
+ {
22
+ // tests routinely need `let` in beforeEach setup, mock mutation, and
23
+ // sometimes class-based fixtures — same spirit as baseTestOverrides.
24
+ files: ['**/*.test.ts'],
25
+ rules: {
26
+ 'functional/immutable-data': 'off',
27
+ 'functional/no-classes': 'off',
28
+ 'functional/no-let': 'off',
29
+ 'functional/no-this-expressions': 'off',
30
+ },
31
+ },
32
+ ]
33
+
34
+ export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allthings/eslint-config",
3
- "version": "3.7.1-alpha.1",
3
+ "version": "3.8.0-alpha.1",
4
4
  "type": "module",
5
5
  "description": "ESlint shareable config for Allthings style",
6
6
  "main": "index.js",
@@ -10,10 +10,12 @@
10
10
  },
11
11
  "exports": {
12
12
  ".": "./index.js",
13
+ "./functional": "./functional.js",
13
14
  "./node": "./node.js"
14
15
  },
15
16
  "files": [
16
17
  "base.js",
18
+ "functional.js",
17
19
  "index.js",
18
20
  "node.js"
19
21
  ],
@@ -35,6 +37,7 @@
35
37
  "eslint-config-prettier": "^10.1.8",
36
38
  "eslint-import-resolver-node": "^0.4.0",
37
39
  "eslint-import-resolver-typescript": "^4.4.4",
40
+ "eslint-plugin-functional": "^9.0.5",
38
41
  "eslint-plugin-import": "^2.32.0",
39
42
  "eslint-plugin-jest": "^29.0.0",
40
43
  "eslint-plugin-jsx-a11y": "^6.10.2",