@blumintinc/eslint-plugin-blumint 0.1.23 → 1.0.2

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 (52) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +277 -55
  3. package/assets/logo.svg +26 -0
  4. package/jest.config.js +13 -0
  5. package/package.json +74 -25
  6. package/plugin/README.md +80 -0
  7. package/{docs → plugin/docs}/rules/class-methods-read-top-to-bottom.md +3 -1
  8. package/{docs → plugin/docs}/rules/dynamic-https-errors.md +1 -1
  9. package/{docs → plugin/docs}/rules/require-memo.md +9 -2
  10. package/plugin/package-lock.json +7662 -0
  11. package/plugin/package.json +45 -0
  12. package/tsconfig.json +79 -0
  13. package/lib/index.js +0 -69
  14. package/lib/rules/array-methods-this-context.js +0 -64
  15. package/lib/rules/class-methods-read-top-to-bottom.js +0 -72
  16. package/lib/rules/dynamic-https-errors.js +0 -57
  17. package/lib/rules/export-if-in-doubt.js +0 -69
  18. package/lib/rules/extract-global-constants.js +0 -63
  19. package/lib/rules/generic-starts-with-t.js +0 -35
  20. package/lib/rules/no-async-array-filter.js +0 -40
  21. package/lib/rules/no-async-foreach.js +0 -37
  22. package/lib/rules/no-conditional-literals-in-jsx.js +0 -61
  23. package/lib/rules/no-filter-without-return.js +0 -41
  24. package/lib/rules/no-misused-switch-case.js +0 -35
  25. package/lib/rules/no-unpinned-dependencies.js +0 -65
  26. package/lib/rules/no-useless-fragment.js +0 -46
  27. package/lib/rules/prefer-fragment-shorthand.js +0 -40
  28. package/lib/rules/prefer-type-over-interface.js +0 -45
  29. package/lib/rules/require-memo.js +0 -134
  30. package/lib/utils/ASTHelpers.js +0 -336
  31. package/lib/utils/ClassGraphBuilder.js +0 -80
  32. package/lib/utils/ClassGraphSorter.js +0 -99
  33. package/lib/utils/createRule.js +0 -6
  34. package/lib/utils/graph/ClassGraphBuilder.js +0 -80
  35. package/lib/utils/graph/ClassGraphSorter.js +0 -10
  36. package/lib/utils/graph/ClassGraphSorterReadability.js +0 -94
  37. package/lib/utils/graph.js +0 -109
  38. package/lib/utils/ruleTester.js +0 -23
  39. package/lib/utils/testClass.js +0 -45
  40. /package/{docs → plugin/docs}/rules/array-methods-this-context.md +0 -0
  41. /package/{docs → plugin/docs}/rules/export-if-in-doubt.md +0 -0
  42. /package/{docs → plugin/docs}/rules/extract-global-constants.md +0 -0
  43. /package/{docs → plugin/docs}/rules/generic-starts-with-t.md +0 -0
  44. /package/{docs → plugin/docs}/rules/no-async-array-filter.md +0 -0
  45. /package/{docs → plugin/docs}/rules/no-async-foreach.md +0 -0
  46. /package/{docs → plugin/docs}/rules/no-conditional-literals-in-jsx.md +0 -0
  47. /package/{docs → plugin/docs}/rules/no-filter-without-return.md +0 -0
  48. /package/{docs → plugin/docs}/rules/no-misused-switch-case.md +0 -0
  49. /package/{docs → plugin/docs}/rules/no-unpinned-dependencies.md +0 -0
  50. /package/{docs → plugin/docs}/rules/no-useless-fragment.md +0 -0
  51. /package/{docs → plugin/docs}/rules/prefer-fragment-shorthand.md +0 -0
  52. /package/{docs → plugin/docs}/rules/prefer-type-over-interface.md +0 -0
@@ -0,0 +1,80 @@
1
+ # @blumintinc/eslint-plugin-blumint
2
+
3
+ Custom eslint rules for use at BluMint
4
+
5
+ ## Installation
6
+
7
+ You'll first need to install [ESLint](https://eslint.org/):
8
+
9
+ ```sh
10
+ npm i eslint --save-dev
11
+ ```
12
+
13
+ Next, install `@blumintinc/eslint-plugin-blumint`:
14
+
15
+ ```sh
16
+ npm install @blumintinc/eslint-plugin-blumint --save-dev
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ Add `@blumintinc/blumint` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
22
+
23
+ ```json
24
+ {
25
+ "plugins": [
26
+ "@blumintinc/blumint"
27
+ ]
28
+ }
29
+ ```
30
+
31
+
32
+ Then configure the rules you want to use under the rules section.
33
+
34
+ ```json
35
+ {
36
+ "rules": {
37
+ "blumint/rule-name": "error"
38
+ }
39
+ }
40
+ ```
41
+
42
+ Or use the recommended config:
43
+
44
+ ```json
45
+ {
46
+ "extends": ["some-other-plugin", "plugin:@blumintinc/blumint/recommended"]
47
+ }
48
+ ```
49
+
50
+ ## Rules
51
+
52
+ <!-- begin auto-generated rules list -->
53
+
54
+ 💼 Configurations enabled in.\
55
+ ⚠️ Configurations set to warn in.\
56
+ ✅ Set in the `recommended` configuration.\
57
+ 🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
58
+
59
+ | Name                             | Description | 💼 | ⚠️ | 🔧 |
60
+ | :--------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
61
+ | [array-methods-this-context](docs/rules/array-methods-this-context.md) | Prevent misuse of Array methods in OOP | | ✅ | |
62
+ | [class-methods-read-top-to-bottom](docs/rules/class-methods-read-top-to-bottom.md) | Ensures classes read linearly from top to bottom. | | ✅ | 🔧 |
63
+ | [dynamic-https-errors](docs/rules/dynamic-https-errors.md) | Dynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id. | | ✅ | |
64
+ | [export-if-in-doubt](docs/rules/export-if-in-doubt.md) | All top-level const definitions, type definitions, and functions should be exported | | | |
65
+ | [extract-global-constants](docs/rules/extract-global-constants.md) | Extract constants/functions to the global scope when possible | | | |
66
+ | [generic-starts-with-t](docs/rules/generic-starts-with-t.md) | Enforce TypeScript generic types to start with T | | ✅ | |
67
+ | [no-async-array-filter](docs/rules/no-async-array-filter.md) | Disallow async callbacks for Array.filter | ✅ | | |
68
+ | [no-async-foreach](docs/rules/no-async-foreach.md) | Disallow Array.forEach with an async callback function | ✅ | | |
69
+ | [no-conditional-literals-in-jsx](docs/rules/no-conditional-literals-in-jsx.md) | Disallow use of conditional literals in JSX code | ✅ | | |
70
+ | [no-filter-without-return](docs/rules/no-filter-without-return.md) | Disallow Array.filter callbacks without an explicit return (if part of a block statement) | ✅ | | |
71
+ | [no-misused-switch-case](docs/rules/no-misused-switch-case.md) | Prevent misuse of logical OR in switch case statements | ✅ | | |
72
+ | [no-unpinned-dependencies](docs/rules/no-unpinned-dependencies.md) | Enforces pinned dependencies | ✅ | | 🔧 |
73
+ | [no-useless-fragment](docs/rules/no-useless-fragment.md) | Prevent unnecessary use of React fragments | | ✅ | 🔧 |
74
+ | [prefer-fragment-shorthand](docs/rules/prefer-fragment-shorthand.md) | Prefer <> shorthand for <React.Fragment> | | ✅ | 🔧 |
75
+ | [prefer-type-over-interface](docs/rules/prefer-type-over-interface.md) | Prefer using type alias over interface | | ✅ | 🔧 |
76
+ | [require-memo](docs/rules/require-memo.md) | React components must be memoized | ✅ | | 🔧 |
77
+
78
+ <!-- end auto-generated rules list -->
79
+
80
+
@@ -1,7 +1,9 @@
1
- # Try to keep classes reading top to bottom (`@blumintinc/blumint/class-methods-read-top-to-bottom`)
1
+ # Ensures classes read linearly from top to bottom (`@blumintinc/blumint/class-methods-read-top-to-bottom`)
2
2
 
3
3
  ⚠️ This rule _warns_ in the ✅ `recommended` config.
4
4
 
5
+ 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
+
5
7
  <!-- end auto-generated rule header -->
6
8
 
7
9
  This rule enforces an ordering of class methods according to BluMint's code style.
@@ -1,4 +1,4 @@
1
- # Dynamic elements of errors should be in the 'details' field (`@blumintinc/blumint/dynamic-https-errors`)
1
+ # Dynamic error details should only be in the third argument of the HttpsError constructor. The second argument is hashed to produce a unique id (`@blumintinc/blumint/dynamic-https-errors`)
2
2
 
3
3
  ⚠️ This rule _warns_ in the ✅ `recommended` config.
4
4
 
@@ -1,8 +1,12 @@
1
- # Requires memoization of react components (`@blumintinc/blumint/require-memo`)
1
+ # React components must be memoized (`@blumintinc/blumint/require-memo`)
2
+
3
+ 💼 This rule is enabled in the ✅ `recommended` config.
4
+
5
+ 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
2
6
 
3
7
  <!-- end auto-generated rule header -->
4
8
 
5
- This rule enforces that React components (that are not pure) to be memoized. If the component name includes "Unmemoized", then this rule is ignored.
9
+ This rule enforces that React components (that are not pure) to be memoized using our custom `memo` implementation. The rule supports both absolute imports (`src/util/memo`) and relative imports (`../util/memo`) based on the file location. If the component name includes "Unmemoized", then this rule is ignored.
6
10
 
7
11
  ## Rule Details
8
12
 
@@ -17,11 +21,14 @@ const Component = ({foo, bar}) => return (
17
21
  Examples of **correct** code for this rule:
18
22
 
19
23
  ```jsx
24
+ import { memo } from 'src/util/memo';
25
+
20
26
  const MemoizedComponent = memo(function BigComponent({foo, bar}) {
21
27
  return (
22
28
  <SomeOtherComponent>{foo}{bar}</SomeOtherComponent>
23
29
  )
24
30
  })
31
+
25
32
  const ComponentUnmemoized = ({foo, bar}) => return (
26
33
  <SomeOtherComponent>{foo}{bar}</SomeOtherComponent>
27
34
  )