@moso/eslint-config 3.4.0 → 3.5.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/dist/index.d.mts +673 -407
  2. package/dist/index.mjs +86 -48
  3. package/package.json +24 -23
package/dist/index.mjs CHANGED
@@ -315,11 +315,11 @@ const astro = async (options) => {
315
315
  //#region src/configs/baseline.ts
316
316
  const defaultIgnoreFeatures = ["functions-caller-arguments"];
317
317
  const baseline = async (options) => {
318
- const { baseline, files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
318
+ const { baseline = "widely", files, filesTypeAware, hasDOM, ignoreFeatures, ignoreNodeTypes, ignoresTypeAware, overrides, overridesTypeAware, parserOptions, projectRoot, typescript } = options;
319
319
  const isTypeAware = typescript && typeof projectRoot === "string" && parserOptions?.projectService !== false;
320
320
  const [baselinePlugin] = await loadPackages(["eslint-plugin-baseline-js"]);
321
321
  const baselineRule = (typeAware) => ({ "baseline-js/use-baseline": ["warn", {
322
- available: baseline ?? "widely",
322
+ available: baseline,
323
323
  ignoreFeatures: [...defaultIgnoreFeatures, ...ignoreFeatures ?? []],
324
324
  ignoreNodeTypes,
325
325
  includeJsBuiltins: { preset: typeAware ? "type-aware" : "auto" },
@@ -661,7 +661,8 @@ const comments = async (options) => {
661
661
  //#endregion
662
662
  //#region src/configs/functional.ts
663
663
  const functional = async (options) => {
664
- const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, stylistic } = options;
664
+ const { filesTypeAware, functionalEnforcement, ignoreNamePattern, mode, overrides, parserOptions, stylistic } = options;
665
+ const isTypeAware = parserOptions.projectService !== false;
665
666
  const [functionalPlugin] = await loadPackages(["eslint-plugin-functional"]);
666
667
  const stylisticEnabled = stylistic !== false;
667
668
  const commonRules = {
@@ -758,7 +759,7 @@ const functional = async (options) => {
758
759
  }
759
760
  }, {
760
761
  name: "moso/functional/disable-type-aware",
761
- ignores: filesTypeAware,
762
+ ...isTypeAware && { ignores: filesTypeAware },
762
763
  rules: {
763
764
  ...(assert.ok(!Array.isArray(functionalPlugin.configs.disableTypeChecked)), functionalPlugin.configs.disableTypeChecked.rules),
764
765
  "functional/no-let": ["error", {
@@ -1336,7 +1337,7 @@ const ruleNoUnneededArrayFlatMap = createRule({
1336
1337
  });
1337
1338
  //#endregion
1338
1339
  //#region src/rules/package.json
1339
- var version = "3.4.0";
1340
+ var version = "3.5.0";
1340
1341
  //#endregion
1341
1342
  //#region src/rules/prefer-early-return/prefer-early-return.ts
1342
1343
  const isTriggering = (node, maximumStatements) => {
@@ -2120,7 +2121,7 @@ const jsdoc = async (options) => {
2120
2121
  ],
2121
2122
  "jsdoc/valid-types": "error",
2122
2123
  ...!lessOpinionated && {
2123
- "jsdoc/check-indentation": "warn",
2124
+ "jsdoc/check-indentation": ["warn", { allowNoSpaceAfterAsterisk: true }],
2124
2125
  "jsdoc/no-bad-blocks": ["warn", { ignore: [
2125
2126
  "ts-check",
2126
2127
  "ts-expect-error",
@@ -2934,12 +2935,35 @@ const regexp = async (options) => {
2934
2935
  "no-invalid-regexp": "off",
2935
2936
  "no-useless-backreference": "off",
2936
2937
  ...(assert.ok(!Array.isArray(regexpPlugin.configs["flat/recommended"])), regexpPlugin.configs["flat/recommended"].rules),
2938
+ "regexp/no-super-linear-backtracking": "error",
2937
2939
  "regexp/strict": "off",
2938
2940
  ...overrides
2939
2941
  }
2940
2942
  }];
2941
2943
  };
2942
2944
  //#endregion
2945
+ //#region src/configs/security.ts
2946
+ const security = async (options) => {
2947
+ const { overrides, severity } = options;
2948
+ const [securityPlugin] = await loadPackages(["eslint-plugin-security"]);
2949
+ const recommended = securityPlugin.configs?.["recommended"];
2950
+ const baseRules = severity === "lite" ? recommended?.rules : Object.fromEntries(Object.keys(recommended?.rules ?? {}).map((key) => [key, "error"]));
2951
+ return [{
2952
+ name: "moso/security",
2953
+ plugins: { security: memoize(securityPlugin, "eslint-plugin-security") },
2954
+ rules: {
2955
+ ...baseRules,
2956
+ "security/detect-unsafe-regex": "off",
2957
+ ...severity !== "strict" && {
2958
+ "security/detect-non-literal-fs-filename": "off",
2959
+ "security/detect-non-literal-regexp": "off",
2960
+ "security/detect-object-injection": "off"
2961
+ },
2962
+ ...overrides
2963
+ }
2964
+ }];
2965
+ };
2966
+ //#endregion
2943
2967
  //#region src/configs/sort.ts
2944
2968
  /**
2945
2969
  * Sort package.json
@@ -3660,45 +3684,47 @@ const typescript = async (options) => {
3660
3684
  "@typescript-eslint/no-useless-constructor": "error",
3661
3685
  "@typescript-eslint/parameter-properties": "off",
3662
3686
  ...functionalEnforcement !== "none" && mode !== "library" && {
3663
- "functional/no-mixed-types": "error",
3664
- "functional/prefer-property-signatures": "error",
3665
- "functional/readonly-type": "error",
3666
- "functional/type-declaration-immutability": ["error", { rules: [
3667
- {
3668
- identifiers: "I?Immutable.+",
3669
- immutability: "Immutable",
3670
- comparator: "AtLeast"
3671
- },
3672
- {
3673
- identifiers: "I?ReadonlyDeep.+",
3674
- immutability: "ReadonlyDeep",
3675
- comparator: "AtLeast"
3676
- },
3677
- {
3678
- identifiers: "I?Readonly.+",
3679
- immutability: "ReadonlyShallow",
3680
- comparator: "AtLeast",
3681
- fixer: [{
3682
- pattern: "^(Array|Map|Set)<(.+)>$",
3683
- replace: "Readonly$1<$2>"
3684
- }, {
3685
- pattern: "^(.+)$",
3686
- replace: "Readonly<$1>"
3687
- }]
3688
- },
3689
- {
3690
- identifiers: "I?Mutable.+",
3691
- immutability: "Mutable",
3692
- comparator: "AtMost",
3693
- fixer: [{
3694
- pattern: "^Readonly(Array|Map|Set)<(.+)>$",
3695
- replace: "$1<$2>"
3696
- }, {
3697
- pattern: "^Readonly<(.+)>$",
3698
- replace: "$1"
3699
- }]
3700
- }
3701
- ] }],
3687
+ ...isTypeAware && {
3688
+ "functional/no-mixed-types": "error",
3689
+ "functional/prefer-property-signatures": "error",
3690
+ "functional/readonly-type": "error",
3691
+ "functional/type-declaration-immutability": ["error", { rules: [
3692
+ {
3693
+ identifiers: "I?Immutable.+",
3694
+ immutability: "Immutable",
3695
+ comparator: "AtLeast"
3696
+ },
3697
+ {
3698
+ identifiers: "I?ReadonlyDeep.+",
3699
+ immutability: "ReadonlyDeep",
3700
+ comparator: "AtLeast"
3701
+ },
3702
+ {
3703
+ identifiers: "I?Readonly.+",
3704
+ immutability: "ReadonlyShallow",
3705
+ comparator: "AtLeast",
3706
+ fixer: [{
3707
+ pattern: "^(Array|Map|Set)<(.+)>$",
3708
+ replace: "Readonly$1<$2>"
3709
+ }, {
3710
+ pattern: "^(.+)$",
3711
+ replace: "Readonly<$1>"
3712
+ }]
3713
+ },
3714
+ {
3715
+ identifiers: "I?Mutable.+",
3716
+ immutability: "Mutable",
3717
+ comparator: "AtMost",
3718
+ fixer: [{
3719
+ pattern: "^Readonly(Array|Map|Set)<(.+)>$",
3720
+ replace: "$1<$2>"
3721
+ }, {
3722
+ pattern: "^Readonly<(.+)>$",
3723
+ replace: "$1"
3724
+ }]
3725
+ }
3726
+ ] }]
3727
+ },
3702
3728
  "@typescript-eslint/naming-convention": [
3703
3729
  "error",
3704
3730
  {
@@ -4163,6 +4189,7 @@ const unicorn = async (options) => {
4163
4189
  "unicorn/try-complexity": ["error", { max: 3 }],
4164
4190
  "unicorn/consistent-boolean-name": "off",
4165
4191
  "unicorn/consistent-compound-words": "off",
4192
+ "unicorn/consistent-conditional-object-spread": "off",
4166
4193
  "unicorn/consistent-export-decorator-position": "off",
4167
4194
  "unicorn/default-export-style": "off",
4168
4195
  "unicorn/empty-brace-spaces": "off",
@@ -4175,6 +4202,7 @@ const unicorn = async (options) => {
4175
4202
  "unicorn/logical-assignment-operators": "off",
4176
4203
  "unicorn/max-nested-calls": "off",
4177
4204
  "unicorn/name-replacements": "off",
4205
+ "unicorn/no-asterisk-prefix-in-documentation-comments": "off",
4178
4206
  "unicorn/no-array-concat-in-loop": "off",
4179
4207
  "unicorn/no-array-fill-with-reference-type": "off",
4180
4208
  "unicorn/no-array-reduce": "off",
@@ -4191,6 +4219,7 @@ const unicorn = async (options) => {
4191
4219
  "unicorn/no-invalid-well-known-symbol-methods": "off",
4192
4220
  "unicorn/no-late-current-target-access": "off",
4193
4221
  "unicorn/no-late-event-control": "off",
4222
+ "unicorn/no-leading-empty-lines": "off",
4194
4223
  "unicorn/no-lonely-if": "off",
4195
4224
  "unicorn/no-mismatched-map-key": "off",
4196
4225
  "unicorn/no-named-default": "off",
@@ -4225,6 +4254,7 @@ const unicorn = async (options) => {
4225
4254
  "unicorn/prefer-promise-try": "off",
4226
4255
  "unicorn/prefer-promise-with-resolvers": "off",
4227
4256
  "unicorn/prefer-prototype-methods": "off",
4257
+ "unicorn/prefer-short-escape-sequences": "off",
4228
4258
  "unicorn/prefer-single-replace": "off",
4229
4259
  "unicorn/prefer-split-limit": "off",
4230
4260
  "unicorn/prefer-string-raw": "off",
@@ -4585,12 +4615,13 @@ async function moso(options = {}, ...userConfigs) {
4585
4615
  const ignoreOptions = typeof options.ignores === "object" ? options.ignores : {};
4586
4616
  const modeOptions = typeof options.mode === "string" ? options.mode : "none";
4587
4617
  const perfectionistOptions = typeof options.perfectionist === "boolean" ? options.perfectionist : options.lessOpinionated !== true;
4618
+ const securityOptions = typeof options.security === "string" ? options.security : typeof options.security === "object" ? options.security.severity ?? "moderate" : options.security === false ? "none" : "moderate";
4588
4619
  const stylisticOptions = options.stylistic !== false && {
4589
4620
  ...StylisticConfigDefaults,
4590
4621
  jsx: jsxOptions !== false,
4591
4622
  ...typeof options.stylistic === "object" && options.stylistic
4592
4623
  };
4593
- const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe, useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
4624
+ const { filesTypeAware, ignoresTypeAware, parserOptions, projectRoot: typescriptProjectRoot, unsafe: typescriptUnsafe = "warn", useDefaultDefaultProject, ...typescriptSubOptions } = resolveSubOptions(options, "typescript");
4594
4625
  const deprecatedProjectRoot = options.projectRoot;
4595
4626
  if (deprecatedProjectRoot !== void 0) console.warn("[@moso/eslint-config] The top-level `projectRoot` option is deprecated. Move it inside the `typescript` options instead: `typescript: { projectRoot: import.meta.dirname }`.");
4596
4627
  const projectRootOptions = typeof typescriptProjectRoot === "string" ? checkFilePath(typescriptProjectRoot) : typeof deprecatedProjectRoot === "string" ? checkFilePath(deprecatedProjectRoot) : void 0;
@@ -4639,6 +4670,11 @@ async function moso(options = {}, ...userConfigs) {
4639
4670
  stylistic: stylisticOptions,
4640
4671
  typescript: hasTypeScript
4641
4672
  }));
4673
+ if (securityOptions !== "none") mut_configs.push(security({
4674
+ ...resolveSubOptions(options, "security"),
4675
+ overrides: getOverrides(options, "security"),
4676
+ severity: securityOptions
4677
+ }));
4642
4678
  mut_configs.push(javascript({
4643
4679
  ...functionalConfigOptions,
4644
4680
  isInEditor,
@@ -4774,7 +4810,7 @@ async function moso(options = {}, ...userConfigs) {
4774
4810
  overrides: getOverrides(options, "typescript"),
4775
4811
  projectRoot: projectRootOptions,
4776
4812
  stylistic: stylisticOptions,
4777
- unsafe: typescriptUnsafe ?? "warn"
4813
+ unsafe: typescriptUnsafe
4778
4814
  }));
4779
4815
  if (vueOptions !== false) mut_configs.push(vue({
4780
4816
  ...typescriptConfigOptions,
@@ -4838,6 +4874,7 @@ const full = {
4838
4874
  reactRefresh: { allowConstantExport: true }
4839
4875
  },
4840
4876
  regexp: true,
4877
+ security: true,
4841
4878
  stylistic: true,
4842
4879
  tailwind: {
4843
4880
  entryPoint: "src/styles/app.css",
@@ -4871,6 +4908,7 @@ const off = {
4871
4908
  promise: false,
4872
4909
  react: false,
4873
4910
  regexp: false,
4911
+ security: false,
4874
4912
  stylistic: false,
4875
4913
  tailwind: false,
4876
4914
  test: false,
@@ -4881,4 +4919,4 @@ const off = {
4881
4919
  yaml: false
4882
4920
  };
4883
4921
  //#endregion
4884
- export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
4922
+ export { GLOB_AI, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CJS, GLOB_CSS_IN_JS, GLOB_DIST, GLOB_DTS, GLOB_EXCLUDE, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MJS, GLOB_NODE_MODULES, GLOB_ROOT_DTS, GLOB_ROOT_JS, GLOB_ROOT_JSX, GLOB_ROOT_TS, GLOB_ROOT_TSX, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_TYPINGS, GLOB_VUE, GLOB_YAML, StylisticConfigDefaults, astro, baseline, checkFilePath, combine, comments, moso as default, moso, disables, e18e, flattenRules, full, functional, getOverrides, globalIgnores, ignores, imports, interopDefault, isInEditorEnv, javascript, jsdoc, jsonc, jsx, memoize, nextjs, node, off, perfectionist, promise, react, regexp, resolveSubOptions, security, sortPackageJson, sortTsconfig, stylistic, tailwind, test, toml, typescript, unicorn, vue, vueInlineElements, yaml };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moso/eslint-config",
3
3
  "type": "module",
4
- "version": "3.4.0",
4
+ "version": "3.5.0",
5
5
  "description": "@moso's sharable ESLint config",
6
6
  "author": {
7
7
  "name": "Morten Sørensen",
@@ -62,12 +62,12 @@
62
62
  "src/rules"
63
63
  ],
64
64
  "peerDependencies": {
65
- "@eslint-react/eslint-plugin": "^5.20.8",
66
- "@next/eslint-plugin-next": "^16.3.6",
65
+ "@eslint-react/eslint-plugin": "^5.24.0",
66
+ "@next/eslint-plugin-next": "^16.4.0",
67
67
  "astro-eslint-parser": "^3.2.0",
68
68
  "eslint": "^10.0.0",
69
69
  "eslint-plugin-astro": "^3.2.1",
70
- "eslint-plugin-better-tailwindcss": "^4.7.0",
70
+ "eslint-plugin-better-tailwindcss": "^4.9.0",
71
71
  "eslint-plugin-erasable-syntax-only": "^0.7.2",
72
72
  "eslint-plugin-jsx-a11y": "^6.10.2",
73
73
  "eslint-plugin-react-hooks": "^7.1.1",
@@ -125,30 +125,31 @@
125
125
  "@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
126
126
  "@eslint/js": "^10.0.1",
127
127
  "@stylistic/eslint-plugin": "^5.10.0",
128
- "@typescript-eslint/eslint-plugin": "^8.70.1",
129
- "@typescript-eslint/parser": "^8.70.1",
130
- "@typescript-eslint/utils": "^8.70.1",
128
+ "@typescript-eslint/eslint-plugin": "^8.71.1",
129
+ "@typescript-eslint/parser": "^8.71.1",
130
+ "@typescript-eslint/utils": "^8.71.1",
131
131
  "@vitest/eslint-plugin": "^1.6.27",
132
132
  "eslint-config-flat-gitignore": "^2.4.0",
133
133
  "eslint-flat-config-utils": "^3.2.0",
134
134
  "eslint-merge-processors": "^2.0.0",
135
- "eslint-plugin-baseline-js": "^0.7.2",
135
+ "eslint-plugin-baseline-js": "^0.7.4",
136
136
  "eslint-plugin-de-morgan": "^2.2.0",
137
137
  "eslint-plugin-functional": "^10.0.1",
138
138
  "eslint-plugin-import-lite": "^0.6.0",
139
- "eslint-plugin-jsdoc": "^64.5.4",
139
+ "eslint-plugin-jsdoc": "^65.2.2",
140
140
  "eslint-plugin-jsonc": "^3.4.2",
141
- "eslint-plugin-n": "^18.3.0",
141
+ "eslint-plugin-n": "^18.4.1",
142
142
  "eslint-plugin-no-only-tests": "^3.4.0",
143
143
  "eslint-plugin-perfectionist": "^5.12.1",
144
144
  "eslint-plugin-promise": "^7.3.0",
145
145
  "eslint-plugin-regexp": "^3.3.1",
146
+ "eslint-plugin-security": "^4.2.0",
146
147
  "eslint-plugin-toml": "^1.5.0",
147
- "eslint-plugin-unicorn": "^76.0.0",
148
+ "eslint-plugin-unicorn": "^77.0.0",
148
149
  "eslint-plugin-unused-imports": "^4.4.1",
149
- "eslint-plugin-yml": "^3.8.1",
150
+ "eslint-plugin-yml": "^3.9.0",
150
151
  "eslint-processor-vue-blocks": "^2.0.0",
151
- "globals": "^17.12.0",
152
+ "globals": "^17.13.0",
152
153
  "jsonc-eslint-parser": "^3.3.0",
153
154
  "local-pkg": "^1.2.1",
154
155
  "toml-eslint-parser": "^1.0.3",
@@ -156,28 +157,28 @@
156
157
  "yaml-eslint-parser": "^2.1.0"
157
158
  },
158
159
  "devDependencies": {
159
- "@eslint-react/eslint-plugin": "^5.20.8",
160
+ "@eslint-react/eslint-plugin": "^5.24.10",
160
161
  "@eslint/compat": "^2.1.1",
161
162
  "@eslint/config-inspector": "^3.5.0",
162
- "@moso/eslint-plugin": "3.3.0",
163
- "@next/eslint-plugin-next": "^16.3.6",
163
+ "@moso/eslint-plugin": "3.4.0",
164
+ "@next/eslint-plugin-next": "^16.4.0",
164
165
  "@socketsecurity/bun-security-scanner": "^1.1.3",
165
166
  "@types/eslint-plugin-jsx-a11y": "^6.10.1",
166
- "@types/node": "^26.6.3",
167
- "@typescript-eslint/rule-tester": "^8.70.1",
168
- "@vitest/coverage-v8": "^5.0.2",
167
+ "@types/node": "^26.6.4",
168
+ "@typescript-eslint/rule-tester": "^8.71.1",
169
+ "@vitest/coverage-v8": "^5.0.3",
169
170
  "astro-eslint-parser": "^3.2.0",
170
171
  "bumpp": "^12.3.0",
171
- "eslint": "^10.11.0",
172
+ "eslint": "^10.12.0",
172
173
  "eslint-plugin-astro": "^3.2.1",
173
- "eslint-plugin-better-tailwindcss": "^4.7.0",
174
+ "eslint-plugin-better-tailwindcss": "^4.9.0",
174
175
  "eslint-plugin-erasable-syntax-only": "^0.7.2",
175
176
  "eslint-plugin-jsx-a11y": "^6.10.2",
176
177
  "eslint-plugin-react-hooks": "^7.1.1",
177
178
  "eslint-plugin-react-refresh": "^0.5.7",
178
179
  "eslint-plugin-react-you-might-not-need-an-effect": "^1.0.2",
179
180
  "eslint-plugin-vue": "^10.11.1",
180
- "eslint-plugin-vuejs-accessibility": "^2.6.0",
181
+ "eslint-plugin-vuejs-accessibility": "^2.6.2",
181
182
  "eslint-typegen": "^2.3.1",
182
183
  "jiti": "^2.7.0",
183
184
  "nano-staged": "^1.0.2",
@@ -186,7 +187,7 @@
186
187
  "tsdown": "^0.23.0",
187
188
  "tsx": "^4.23.15",
188
189
  "typescript": "^6.0.3",
189
- "vitest": "^5.0.2"
190
+ "vitest": "^5.0.3"
190
191
  },
191
192
  "simple-git-hooks": {
192
193
  "pre-commit": "bunx nano-staged"