@forsakringskassan/eslint-config 13.0.2 → 13.0.4

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/index.mjs +72 -2
  2. package/package.json +2 -2
package/index.mjs CHANGED
@@ -11,6 +11,7 @@ export { default as globals } from "globals";
11
11
 
12
12
  /**
13
13
  * @typedef {import("eslint").Linter.Config} Config
14
+ * @typedef {import("eslint").Linter.RulesRecord} RulesRecord
14
15
  */
15
16
 
16
17
  /**
@@ -36,6 +37,17 @@ function merge(result, it) {
36
37
  };
37
38
  }
38
39
 
40
+ /**
41
+ * @param {RulesRecord} rules
42
+ * @param {(rule: string) => boolean} predicate
43
+ * @returns {RulesRecord}
44
+ */
45
+ function filterRules(rules, predicate) {
46
+ return Object.fromEntries(
47
+ Object.entries(rules).filter(([key]) => predicate(key)),
48
+ );
49
+ }
50
+
39
51
  export default [
40
52
  defineConfig({
41
53
  ...js.configs.recommended,
@@ -59,7 +71,27 @@ export default [
59
71
  },
60
72
  },
61
73
  rules: {
62
- ...prettierConfig.rules,
74
+ ...filterRules(prettierConfig.rules, (rule) => {
75
+ if (rule.startsWith("@stylistic/")) {
76
+ return false;
77
+ }
78
+ if (rule.startsWith("@babel/") || rule.startsWith("babel/")) {
79
+ return false;
80
+ }
81
+ if (rule.startsWith("flowtype/")) {
82
+ return false;
83
+ }
84
+ if (rule.startsWith("react/")) {
85
+ return false;
86
+ }
87
+ if (rule.startsWith("standard/")) {
88
+ return false;
89
+ }
90
+ if (rule.startsWith("unicorn/")) {
91
+ return false;
92
+ }
93
+ return true;
94
+ }),
63
95
  ...prettierPlugin.configs.recommended.rules,
64
96
  ...importPlugin.configs.errors.rules,
65
97
  ...eslintCommentsPlugin.configs.recommended.rules,
@@ -86,6 +118,7 @@ export default [
86
118
  "no-unused-vars": "error",
87
119
  "no-var": "error",
88
120
  "no-warning-comments": "error",
121
+ "object-shorthand": "error",
89
122
  "prefer-const": "error",
90
123
  "prefer-rest-params": "error",
91
124
  "prefer-spread": "error",
@@ -125,8 +158,10 @@ export default [
125
158
  "sonarjs/no-duplicate-string": "off",
126
159
 
127
160
  "sonarjs/argument-type": "off", // handled by typescript (and this rule is sometimes wrong)
161
+ "sonarjs/arguments-order": "off", // another slow rule, would be nice to have enabled thought
128
162
  "sonarjs/deprecation": "off", // covered by @typescript-eslint/no-deprecated (and this rule crashes on .svelte files)
129
163
  "sonarjs/function-return-type": "off", // overly broad and opinionated, let typescript deal with this
164
+ "sonarjs/no-commented-code": "off", // neat rule but is very very slow (over 50% of the total linting time)
130
165
  "sonarjs/no-control-regex": "off", // covered by no-control-regexp
131
166
  "sonarjs/no-empty-test-file": "off", // could be useful but it does not handle it.each or similar constructs thus yields more false positives than its worth */
132
167
  "sonarjs/no-selector-parameter": "off", // not always possible (e.g. watcher handler in vue)
@@ -141,6 +176,27 @@ export default [
141
176
  "sonarjs/unused-named-groups": "off", // named groups can help readability even if not used
142
177
  "sonarjs/use-type-alias": "off", // overly broad, lets leave this to the discretion of the author
143
178
 
179
+ /* disable sonarjs aws related rules as we dont use aws */
180
+ "sonarjs/aws-apigateway-public-api": "off",
181
+ "sonarjs/aws-ec2-rds-dms-public": "off",
182
+ "sonarjs/aws-ec2-unencrypted-ebs-volume": "off",
183
+ "sonarjs/aws-efs-unencrypted": "off",
184
+ "sonarjs/aws-iam-all-privileges": "off",
185
+ "sonarjs/aws-iam-all-resources-accessible": "off",
186
+ "sonarjs/aws-iam-privilege-escalation": "off",
187
+ "sonarjs/aws-iam-public-access": "off",
188
+ "sonarjs/aws-opensearchservice-domain": "off",
189
+ "sonarjs/aws-rds-unencrypted-databases": "off",
190
+ "sonarjs/aws-restricted-ip-admin-access": "off",
191
+ "sonarjs/aws-s3-bucket-granted-access": "off",
192
+ "sonarjs/aws-s3-bucket-insecure-http": "off",
193
+ "sonarjs/aws-s3-bucket-public-access": "off",
194
+ "sonarjs/aws-s3-bucket-server-encryption": "off",
195
+ "sonarjs/aws-s3-bucket-versioning": "off",
196
+ "sonarjs/aws-sagemaker-unencrypted-notebook": "off",
197
+ "sonarjs/aws-sns-unencrypted-topics": "off",
198
+ "sonarjs/aws-sqs-unencrypted-queue": "off",
199
+
144
200
  /* Lower some errors to warnings, these are allowed on local builds (to
145
201
  * not prevent builds during development where code is unfinished and
146
202
  * might contain debugging code) but is disallowed when building from
@@ -148,7 +204,6 @@ export default [
148
204
  "no-console": "warn",
149
205
  "no-debugger": "warn",
150
206
  "prettier/prettier": "warn",
151
- "sonarjs/no-commented-code": "warn",
152
207
 
153
208
  "import/default": "off",
154
209
  "import/extensions": [
@@ -263,6 +318,13 @@ export default [
263
318
  },
264
319
  ];
265
320
 
321
+ const defaultAppConfig = defineConfig({
322
+ name: "@forsakringskassan/eslint-config/app",
323
+ rules: {
324
+ "sonarjs/no-commented-code": "warn",
325
+ },
326
+ });
327
+
266
328
  const defaultDocsConfig = defineConfig({
267
329
  name: "@forsakringskassan/eslint-config/docs-app",
268
330
  files: ["docs/src/*.{js,ts}"],
@@ -297,6 +359,14 @@ const defaultSandboxConfig = {
297
359
  },
298
360
  };
299
361
 
362
+ /**
363
+ * @param {Config} [override]
364
+ * @returns {Config}
365
+ */
366
+ export function appConfig(override) {
367
+ return merge(defaultAppConfig, override ?? {});
368
+ }
369
+
300
370
  /**
301
371
  * @param {Config} [override]
302
372
  * @returns {Config}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/eslint-config",
3
- "version": "13.0.2",
3
+ "version": "13.0.4",
4
4
  "description": "Försäkringskassans eslint shareable config",
5
5
  "keywords": [
6
6
  "eslint"
@@ -41,5 +41,5 @@
41
41
  "engines": {
42
42
  "node": ">= 22.0"
43
43
  },
44
- "gitHead": "99ad23a49dac0b99b44be7190639b0dfb5d27355"
44
+ "gitHead": "82cae99b10877e69524cfa2d74c977cab719cf09"
45
45
  }