@cloudalgo/eslint-plugin-apex 0.1.8 → 0.1.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 +164 -0
  2. package/package.json +5 -4
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # @cloudalgo/eslint-plugin-apex
2
+
3
+ ESLint plugin for Salesforce Apex. Bundles 41 static analysis rules — SOQL/DML in loops, governor-limit violations, taint-tracked security issues, complexity, and best practices — and a custom Apex parser so the whole setup is one dependency.
4
+
5
+ Compatible with ESLint v8 (legacy config) and ESLint v9 (flat config).
6
+
7
+ ---
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ npm install --save-dev @cloudalgo/eslint-plugin-apex eslint
13
+ ```
14
+
15
+ ---
16
+
17
+ ## Setup — ESLint v9 (flat config)
18
+
19
+ ```js
20
+ // eslint.config.js
21
+ import apex from "@cloudalgo/eslint-plugin-apex";
22
+
23
+ export default [
24
+ // recommended: all 41 rules, critical/high → error, others → warn
25
+ ...apex.flatConfigs.recommended,
26
+ ];
27
+ ```
28
+
29
+ With a metadata root for type-aware rules (e.g. `UnguardedCrudOperation`):
30
+
31
+ ```js
32
+ // eslint.config.js
33
+ import apex from "@cloudalgo/eslint-plugin-apex";
34
+
35
+ export default [
36
+ {
37
+ files: ["**/*.cls", "**/*.trigger"],
38
+ languageOptions: {
39
+ parser: apex.parser,
40
+ },
41
+ plugins: { apex: { rules: apex.rules } },
42
+ settings: {
43
+ "apex/metadataRoot": "./force-app/main/default",
44
+ },
45
+ rules: {
46
+ "apex/SoqlInLoop": "error",
47
+ "apex/DmlInLoop": "error",
48
+ "apex/ApexSOQLInjection": "error",
49
+ "apex/UnguardedCrudOperation": "warn",
50
+ },
51
+ },
52
+ ];
53
+ ```
54
+
55
+ ## Setup — ESLint v8 (legacy .eslintrc)
56
+
57
+ ```json
58
+ {
59
+ "extends": ["plugin:apex/recommended"],
60
+ "settings": {
61
+ "apexMetadataRoot": "./force-app/main/default"
62
+ }
63
+ }
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Rules (41)
69
+
70
+ ### Security (10)
71
+ | Rule | Default |
72
+ |------|---------|
73
+ | `apex/ApexSOQLInjection` | error |
74
+ | `apex/ApexOpenRedirect` | error |
75
+ | `apex/ApexSSRF` | error |
76
+ | `apex/ApexXSSFromURLParam` | error |
77
+ | `apex/ApexXSSFromEscapeFalse` | error |
78
+ | `apex/ApexBadCrypto` | error |
79
+ | `apex/ApexSharingViolations` | error |
80
+ | `apex/DatabaseQueryWithVariable` | error |
81
+ | `apex/UnguardedCrudOperation` | error |
82
+ | `apex/ApexCSRF` | warn |
83
+
84
+ ### Performance (6)
85
+ | Rule | Default |
86
+ |------|---------|
87
+ | `apex/SoqlInLoop` | error |
88
+ | `apex/DmlInLoop` | error |
89
+ | `apex/HttpCalloutInLoop` | error |
90
+ | `apex/SoqlInBatchExecute` | warn |
91
+ | `apex/AvoidNonRestrictiveQueries` | warn |
92
+ | `apex/SystemDebugInLoop` | warn |
93
+
94
+ ### Error-Prone (6)
95
+ | Rule | Default |
96
+ |------|---------|
97
+ | `apex/InaccessibleAuraEnabledGetter` | error |
98
+ | `apex/TestMethodsMustBeInTestClasses` | error |
99
+ | `apex/FutureMethodChaining` | error |
100
+ | `apex/EmptyCatchBlock` | warn |
101
+ | `apex/OverrideBothEqualsAndHashcode` | warn |
102
+ | `apex/AvoidHardcodedId` | warn |
103
+
104
+ ### Design (8)
105
+ | Rule | Default |
106
+ |------|---------|
107
+ | `apex/TriggerInlineLogic` | warn |
108
+ | `apex/CyclomaticComplexity` | warn |
109
+ | `apex/CognitiveComplexity` | warn |
110
+ | `apex/AvoidDeeplyNestedIfStmts` | warn |
111
+ | `apex/ExcessiveParameterList` | warn |
112
+ | `apex/ExcessivePublicCount` | warn |
113
+ | `apex/TooManyFields` | warn |
114
+ | `apex/UnusedPrivateMethod` | warn |
115
+
116
+ ### Best Practices (10)
117
+ | Rule | Default |
118
+ |------|---------|
119
+ | `apex/TestWithoutAsserts` | warn |
120
+ | `apex/SeeAllDataTrue` | warn |
121
+ | `apex/HardcodedUrl` | warn |
122
+ | `apex/QueueableWithoutFinalizer` | warn |
123
+ | `apex/AvoidGlobalModifier` | warn |
124
+ | `apex/AvoidFutureAnnotation` | warn |
125
+ | `apex/DebugsShouldUseLoggingLevel` | warn |
126
+ | `apex/ApexAssertionsShouldIncludeMessage` | warn |
127
+ | `apex/ApexUnitTestMethodShouldHaveIsTestAnnotation` | warn |
128
+ | `apex/ApexUnitTestClassShouldHaveRunAs` | warn |
129
+
130
+ ### Code Style (1)
131
+ | Rule | Default |
132
+ |------|---------|
133
+ | `apex/MethodNamingConventions` | warn |
134
+
135
+ ---
136
+
137
+ ## Suppression
138
+
139
+ Standard ESLint inline suppression works:
140
+
141
+ ```apex
142
+ // eslint-disable-next-line apex/SoqlInLoop
143
+ [SELECT Id FROM Account WHERE Id IN :ids];
144
+ ```
145
+
146
+ PMD-style suppression (`// NOPMD`) is also supported via the underlying `@cloudalgo/apex-core` engine.
147
+
148
+ ---
149
+
150
+ ## VS Code integration
151
+
152
+ Install the ESLint VS Code extension. With this plugin configured, Apex lint errors appear inline in the editor on save.
153
+
154
+ ---
155
+
156
+ ## Prefer the CLI?
157
+
158
+ [`@cloudalgo/apex-lint`](https://www.npmjs.com/package/@cloudalgo/apex-lint) runs the same 41 rules without requiring an ESLint setup — useful for CI scripts, pre-commit hooks, and editors without ESLint integration.
159
+
160
+ ---
161
+
162
+ ## Repository
163
+
164
+ [github.com/cloudalgo/apex-lint](https://github.com/cloudalgo/apex-lint) · License: BSD-3-Clause
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudalgo/eslint-plugin-apex",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "ESLint plugin for Salesforce Apex — 15 rules for SOQL injection, governor limits, security and code quality",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,11 +9,12 @@
9
9
  ".": "./dist/index.js"
10
10
  },
11
11
  "files": [
12
- "dist"
12
+ "dist",
13
+ "README.md"
13
14
  ],
14
15
  "dependencies": {
15
- "@cloudalgo/apex-core": "0.1.8",
16
- "@cloudalgo/eslint-parser-apex": "0.1.8"
16
+ "@cloudalgo/apex-core": "0.1.9",
17
+ "@cloudalgo/eslint-parser-apex": "0.1.9"
17
18
  },
18
19
  "peerDependencies": {
19
20
  "eslint": ">=8.0.0"