@so1ve/eslint-config 1.0.0-alpha.3 → 1.0.0-alpha.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.
package/dist/index.cjs CHANGED
@@ -864,239 +864,233 @@ function warnUnnecessaryOffRules() {
864
864
  }
865
865
  }
866
866
 
867
- const typescript = ({
867
+ function typescript({
868
868
  componentExts = [],
869
+ parserOptions,
869
870
  overrides
870
- } = {}) => [
871
- {
872
- // Install the plugins without globs, so they can be configured separately.
873
- plugins: {
874
- import: pluginImport__default["default"],
875
- ts: pluginTs__default["default"]
876
- }
877
- },
878
- {
879
- files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
880
- languageOptions: {
881
- parser: parserTs__default["default"],
882
- parserOptions: {
883
- sourceType: "module"
871
+ } = {}) {
872
+ const typeAwareRules = {
873
+ "etc/no-assign-mutated-array": "error",
874
+ "etc/no-deprecated": "warn",
875
+ "etc/no-internal": "error",
876
+ "no-throw-literal": "off",
877
+ "ts/no-throw-literal": "error",
878
+ "no-implied-eval": "off",
879
+ "ts/no-implied-eval": "error",
880
+ "dot-notation": "off",
881
+ "ts/dot-notation": ["error", { allowKeywords: true }],
882
+ "no-void": ["error", { allowAsStatement: true }],
883
+ "ts/await-thenable": "error",
884
+ "ts/no-for-in-array": "error",
885
+ "ts/no-unnecessary-type-assertion": "error",
886
+ "ts/restrict-template-expressions": [
887
+ "error",
888
+ {
889
+ allowAny: true,
890
+ allowNumber: true,
891
+ allowBoolean: true
884
892
  }
885
- },
886
- settings: {
887
- "import/resolver": {
888
- node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
889
- typescript: {
890
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
891
- }
893
+ ],
894
+ "ts/array-type": ["error", { default: "array", readonly: "array" }],
895
+ "ts/consistent-generic-constructors": "error",
896
+ "ts/consistent-type-exports": "error",
897
+ "ts/consistent-type-assertions": [
898
+ "error",
899
+ { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
900
+ ],
901
+ "ts/prefer-nullish-coalescing": "error",
902
+ "ts/prefer-optional-chain": "error",
903
+ "ts/prefer-return-this-type": "error",
904
+ "ts/no-unnecessary-type-arguments": "error",
905
+ "ts/non-nullable-type-assertion-style": "error"
906
+ };
907
+ return [
908
+ {
909
+ // Install the plugins without globs, so they can be configured separately.
910
+ plugins: {
911
+ import: pluginImport__default["default"],
912
+ ts: pluginTs__default["default"],
913
+ etc: pluginEtc__default["default"]
892
914
  }
893
915
  },
894
- rules: {
895
- ...renameRules(
896
- pluginTs__default["default"].configs["eslint-recommended"].overrides[0].rules,
897
- "@typescript-eslint/",
898
- "ts/"
899
- ),
900
- ...renameRules(
901
- pluginTs__default["default"].configs.recommended.rules,
902
- "@typescript-eslint/",
903
- "ts/"
904
- ),
905
- "import/named": "off",
906
- // TS
907
- "ts/comma-dangle": "off",
908
- "ts/brace-style": "off",
909
- "ts/comma-spacing": "off",
910
- "ts/func-call-spacing": "off",
911
- "ts/indent": "off",
912
- "ts/keyword-spacing": "off",
913
- "ts/member-delimiter-style": "off",
914
- "ts/no-extra-parens": "off",
915
- "ts/no-extra-semi": "off",
916
- "ts/quotes": "off",
917
- "ts/semi": "off",
918
- "ts/space-before-function-paren": "off",
919
- "ts/type-annotation-spacing": "off",
920
- "ts/ban-ts-comment": [
921
- "error",
922
- {
923
- minimumDescriptionLength: 0
916
+ {
917
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
918
+ languageOptions: {
919
+ parser: parserTs__default["default"],
920
+ parserOptions: {
921
+ sourceType: "module",
922
+ EXPERIMENTAL_useProjectService: true,
923
+ ...parserOptions
924
924
  }
925
- ],
926
- "ts/ban-types": [
927
- "error",
928
- {
929
- extendDefaults: false,
930
- types: {
931
- String: {
932
- message: "Use `string` instead.",
933
- fixWith: "string"
934
- },
935
- Number: {
936
- message: "Use `number` instead.",
937
- fixWith: "number"
938
- },
939
- Boolean: {
940
- message: "Use `boolean` instead.",
941
- fixWith: "boolean"
942
- },
943
- Symbol: {
944
- message: "Use `symbol` instead.",
945
- fixWith: "symbol"
946
- },
947
- BigInt: {
948
- message: "Use `bigint` instead.",
949
- fixWith: "bigint"
950
- },
951
- Object: {
952
- message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
953
- fixWith: "Record<PropertyKey, unknown>"
954
- },
955
- object: {
956
- message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
957
- fixWith: "Record<PropertyKey, unknown>"
958
- },
959
- Function: {
960
- message: "Use `(...args: any[]) => any` instead.",
961
- fixWith: "(...args: any[]) => any"
925
+ },
926
+ settings: {
927
+ "import/resolver": {
928
+ node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
929
+ typescript: {
930
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
931
+ }
932
+ }
933
+ },
934
+ rules: {
935
+ ...renameRules(
936
+ pluginTs__default["default"].configs["eslint-recommended"].overrides[0].rules,
937
+ "@typescript-eslint/",
938
+ "ts/"
939
+ ),
940
+ ...renameRules(
941
+ pluginTs__default["default"].configs.recommended.rules,
942
+ "@typescript-eslint/",
943
+ "ts/"
944
+ ),
945
+ "import/named": "off",
946
+ // TS
947
+ "ts/comma-dangle": "off",
948
+ "ts/brace-style": "off",
949
+ "ts/comma-spacing": "off",
950
+ "ts/func-call-spacing": "off",
951
+ "ts/indent": "off",
952
+ "ts/keyword-spacing": "off",
953
+ "ts/member-delimiter-style": "off",
954
+ "ts/no-extra-parens": "off",
955
+ "ts/no-extra-semi": "off",
956
+ "ts/quotes": "off",
957
+ "ts/semi": "off",
958
+ "ts/space-before-function-paren": "off",
959
+ "ts/type-annotation-spacing": "off",
960
+ "ts/ban-ts-comment": [
961
+ "error",
962
+ {
963
+ minimumDescriptionLength: 0
964
+ }
965
+ ],
966
+ "ts/ban-types": [
967
+ "error",
968
+ {
969
+ extendDefaults: false,
970
+ types: {
971
+ String: {
972
+ message: "Use `string` instead.",
973
+ fixWith: "string"
974
+ },
975
+ Number: {
976
+ message: "Use `number` instead.",
977
+ fixWith: "number"
978
+ },
979
+ Boolean: {
980
+ message: "Use `boolean` instead.",
981
+ fixWith: "boolean"
982
+ },
983
+ Symbol: {
984
+ message: "Use `symbol` instead.",
985
+ fixWith: "symbol"
986
+ },
987
+ BigInt: {
988
+ message: "Use `bigint` instead.",
989
+ fixWith: "bigint"
990
+ },
991
+ Object: {
992
+ message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
993
+ fixWith: "Record<PropertyKey, unknown>"
994
+ },
995
+ object: {
996
+ message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
997
+ fixWith: "Record<PropertyKey, unknown>"
998
+ },
999
+ Function: {
1000
+ message: "Use `(...args: any[]) => any` instead.",
1001
+ fixWith: "(...args: any[]) => any"
1002
+ }
962
1003
  }
963
1004
  }
1005
+ ],
1006
+ "ts/consistent-type-imports": [
1007
+ "error",
1008
+ { prefer: "type-imports", disallowTypeAnnotations: false }
1009
+ ],
1010
+ "ts/consistent-type-definitions": ["error", "interface"],
1011
+ "ts/consistent-indexed-object-style": ["error", "record"],
1012
+ "ts/prefer-ts-expect-error": "error",
1013
+ "ts/no-require-imports": "error",
1014
+ "ts/method-signature-style": ["error", "property"],
1015
+ // Override JS
1016
+ "no-useless-constructor": "off",
1017
+ "no-invalid-this": "off",
1018
+ "ts/no-invalid-this": "error",
1019
+ "no-redeclare": "off",
1020
+ "ts/no-redeclare": "error",
1021
+ "no-use-before-define": "off",
1022
+ "ts/no-use-before-define": [
1023
+ "error",
1024
+ { functions: false, classes: false, variables: true }
1025
+ ],
1026
+ "object-curly-spacing": "off",
1027
+ "space-before-blocks": "off",
1028
+ "ts/space-before-blocks": "off",
1029
+ "space-before-function-paren": "off",
1030
+ "no-dupe-class-members": "off",
1031
+ "ts/no-dupe-class-members": "error",
1032
+ "no-loss-of-precision": "off",
1033
+ "ts/no-loss-of-precision": "error",
1034
+ "lines-between-class-members": "off",
1035
+ "ts/lines-between-class-members": [
1036
+ "error",
1037
+ "always",
1038
+ { exceptAfterSingleLine: true }
1039
+ ],
1040
+ // so1ve
1041
+ "so1ve/no-inline-type-import": "error",
1042
+ // off
1043
+ "ts/camelcase": "off",
1044
+ "ts/explicit-function-return-type": "off",
1045
+ "ts/explicit-member-accessibility": "off",
1046
+ "ts/no-explicit-any": "off",
1047
+ "ts/no-parameter-properties": "off",
1048
+ "ts/no-empty-interface": "off",
1049
+ "ts/ban-ts-ignore": "off",
1050
+ "ts/no-empty-function": "off",
1051
+ "ts/no-non-null-assertion": "off",
1052
+ "ts/explicit-module-boundary-types": "off",
1053
+ "ts/triple-slash-reference": "off",
1054
+ "ts/prefer-for-of": "error",
1055
+ "ts/no-duplicate-enum-values": "error",
1056
+ "ts/no-non-null-asserted-nullish-coalescing": "error",
1057
+ // handled by unused-imports/no-unused-imports
1058
+ "ts/no-unused-vars": "off",
1059
+ ...typeAwareRules,
1060
+ ...overrides
1061
+ }
1062
+ },
1063
+ {
1064
+ files: [GLOB_MARKDOWN_CODE],
1065
+ languageOptions: {
1066
+ parser: parserTs__default["default"],
1067
+ parserOptions: {
1068
+ sourceType: "module"
964
1069
  }
965
- ],
966
- "ts/consistent-type-imports": [
967
- "error",
968
- { prefer: "type-imports", disallowTypeAnnotations: false }
969
- ],
970
- "ts/consistent-type-definitions": ["error", "interface"],
971
- "ts/consistent-indexed-object-style": ["error", "record"],
972
- "ts/prefer-ts-expect-error": "error",
973
- "ts/no-require-imports": "error",
974
- "ts/method-signature-style": ["error", "property"],
975
- // Override JS
976
- "no-useless-constructor": "off",
977
- "no-invalid-this": "off",
978
- "ts/no-invalid-this": "error",
979
- "no-redeclare": "off",
980
- "ts/no-redeclare": "error",
981
- "no-use-before-define": "off",
982
- "ts/no-use-before-define": [
983
- "error",
984
- { functions: false, classes: false, variables: true }
985
- ],
986
- "object-curly-spacing": "off",
987
- "space-before-blocks": "off",
988
- "ts/space-before-blocks": "off",
989
- "space-before-function-paren": "off",
990
- "no-dupe-class-members": "off",
991
- "ts/no-dupe-class-members": "error",
992
- "no-loss-of-precision": "off",
993
- "ts/no-loss-of-precision": "error",
994
- "lines-between-class-members": "off",
995
- "ts/lines-between-class-members": [
996
- "error",
997
- "always",
998
- { exceptAfterSingleLine: true }
999
- ],
1000
- // so1ve
1001
- "so1ve/no-inline-type-import": "error",
1002
- // off
1003
- "ts/camelcase": "off",
1004
- "ts/explicit-function-return-type": "off",
1005
- "ts/explicit-member-accessibility": "off",
1006
- "ts/no-explicit-any": "off",
1007
- "ts/no-parameter-properties": "off",
1008
- "ts/no-empty-interface": "off",
1009
- "ts/ban-ts-ignore": "off",
1010
- "ts/no-empty-function": "off",
1011
- "ts/no-non-null-assertion": "off",
1012
- "ts/explicit-module-boundary-types": "off",
1013
- "ts/triple-slash-reference": "off",
1014
- "ts/prefer-for-of": "error",
1015
- "ts/no-duplicate-enum-values": "error",
1016
- "ts/no-non-null-asserted-nullish-coalescing": "error",
1017
- // handled by unused-imports/no-unused-imports
1018
- "ts/no-unused-vars": "off",
1019
- ...overrides
1020
- }
1021
- },
1022
- {
1023
- files: ["**/*.d.ts"],
1024
- rules: {
1025
- "eslint-comments/no-unlimited-disable": "off",
1026
- "import/no-duplicates": "off",
1027
- "unused-imports/no-unused-vars": "off"
1028
- }
1029
- },
1030
- {
1031
- files: ["**/*.js", "**/*.cjs"],
1032
- rules: {
1033
- "ts/no-require-imports": "off",
1034
- "ts/no-var-requires": "off"
1035
- }
1036
- }
1037
- ];
1038
- const typescriptWithTypes = ({
1039
- componentExts = [],
1040
- tsconfigPath,
1041
- tsconfigRootDir = process.cwd(),
1042
- overrides = {}
1043
- }) => [
1044
- {
1045
- files: [
1046
- GLOB_TS,
1047
- GLOB_TSX,
1048
- ...componentExts.map((ext) => `**/*.${ext}`),
1049
- `!${GLOB_MARKDOWN}/*.*`
1050
- ],
1051
- plugins: {
1052
- etc: pluginEtc__default["default"]
1070
+ },
1071
+ rules: {
1072
+ ...Object.fromEntries(
1073
+ Object.keys(typeAwareRules).map((k) => [k, "off"])
1074
+ )
1075
+ }
1053
1076
  },
1054
- languageOptions: {
1055
- parser: parserTs__default["default"],
1056
- parserOptions: {
1057
- project: [tsconfigPath],
1058
- tsconfigRootDir,
1059
- EXPERIMENTAL_useProjectService: true
1077
+ {
1078
+ files: ["**/*.d.ts"],
1079
+ rules: {
1080
+ "eslint-comments/no-unlimited-disable": "off",
1081
+ "import/no-duplicates": "off",
1082
+ "unused-imports/no-unused-vars": "off"
1060
1083
  }
1061
1084
  },
1062
- rules: {
1063
- "etc/no-assign-mutated-array": "error",
1064
- "etc/no-deprecated": "warn",
1065
- "etc/no-internal": "error",
1066
- "no-throw-literal": "off",
1067
- "ts/no-throw-literal": "error",
1068
- "no-implied-eval": "off",
1069
- "ts/no-implied-eval": "error",
1070
- "dot-notation": "off",
1071
- "ts/dot-notation": ["error", { allowKeywords: true }],
1072
- "no-void": ["error", { allowAsStatement: true }],
1073
- "ts/await-thenable": "error",
1074
- "ts/no-for-in-array": "error",
1075
- "ts/no-unnecessary-type-assertion": "error",
1076
- "ts/restrict-template-expressions": [
1077
- "error",
1078
- {
1079
- allowAny: true,
1080
- allowNumber: true,
1081
- allowBoolean: true
1082
- }
1083
- ],
1084
- "ts/array-type": ["error", { default: "array", readonly: "array" }],
1085
- "ts/consistent-generic-constructors": "error",
1086
- "ts/consistent-type-exports": "error",
1087
- "ts/consistent-type-assertions": [
1088
- "error",
1089
- { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
1090
- ],
1091
- "ts/prefer-nullish-coalescing": "error",
1092
- "ts/prefer-optional-chain": "error",
1093
- "ts/prefer-return-this-type": "error",
1094
- "ts/no-unnecessary-type-arguments": "error",
1095
- "ts/non-nullable-type-assertion-style": "error",
1096
- ...overrides
1085
+ {
1086
+ files: ["**/*.js", "**/*.cjs"],
1087
+ rules: {
1088
+ "ts/no-require-imports": "off",
1089
+ "ts/no-var-requires": "off"
1090
+ }
1097
1091
  }
1098
- }
1099
- ];
1092
+ ];
1093
+ }
1100
1094
 
1101
1095
  const unicorn = () => [
1102
1096
  {
@@ -1419,15 +1413,6 @@ function so1ve(options = {}, ...userConfigs) {
1419
1413
  overrides: overrides.typescript
1420
1414
  })
1421
1415
  );
1422
- if (typeof enableTypeScript !== "boolean") {
1423
- configs.push(
1424
- typescriptWithTypes({
1425
- ...enableTypeScript,
1426
- componentExts,
1427
- overrides: overrides.typescriptWithTypes
1428
- })
1429
- );
1430
- }
1431
1416
  }
1432
1417
  if ((_a = options.test) != null ? _a : true) {
1433
1418
  configs.push(
@@ -1668,7 +1653,6 @@ exports.sortImports = sortImports;
1668
1653
  exports.test = test;
1669
1654
  exports.toml = toml;
1670
1655
  exports.typescript = typescript;
1671
- exports.typescriptWithTypes = typescriptWithTypes;
1672
1656
  exports.unicorn = unicorn;
1673
1657
  exports.vue = vue;
1674
1658
  exports.warnUnnecessaryOffRules = warnUnnecessaryOffRules;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { FlatESLintConfigItem } from 'eslint-define-config';
2
+ import { ParserOptions } from '@typescript-eslint/parser';
3
+ export { default as parserTs } from '@typescript-eslint/parser';
2
4
  import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
3
5
  export { default as pluginComments } from '@eslint-community/eslint-plugin-eslint-comments';
4
6
  export { default as pluginHtml } from '@html-eslint/eslint-plugin';
@@ -6,7 +8,6 @@ export { default as parserHtml } from '@html-eslint/parser';
6
8
  export { default as pluginSo1ve } from '@so1ve/eslint-plugin';
7
9
  export { default as pluginSortImports } from '@so1ve/eslint-plugin-sort-imports';
8
10
  export { default as pluginTs } from '@typescript-eslint/eslint-plugin';
9
- export { default as parserTs } from '@typescript-eslint/parser';
10
11
  export { default as parserMdx } from 'eslint-mdx';
11
12
  export { default as pluginArrayFunc } from 'eslint-plugin-array-func';
12
13
  export { default as pluginEtc } from 'eslint-plugin-etc';
@@ -46,9 +47,11 @@ interface OptionsComponentExts {
46
47
  */
47
48
  componentExts?: string[];
48
49
  }
49
- interface OptionsTypeScriptWithTypes {
50
- tsconfigPath: string;
51
- tsconfigRootDir?: string;
50
+ interface OptionsTypeScriptParserOptions {
51
+ /**
52
+ * Additional parser options for TypeScript.
53
+ */
54
+ parserOptions?: Partial<ParserOptions>;
52
55
  }
53
56
  interface OptionsHasTypeScript {
54
57
  typescript?: boolean;
@@ -73,7 +76,7 @@ interface Options {
73
76
  *
74
77
  * @default auto-detect based on the dependencies
75
78
  */
76
- typescript?: boolean | OptionsTypeScriptWithTypes;
79
+ typescript?: boolean;
77
80
  /**
78
81
  * Enable test support.
79
82
  *
@@ -122,7 +125,6 @@ interface Options {
122
125
  overrides?: {
123
126
  javascript?: FlatESLintConfigItem["rules"];
124
127
  typescript?: FlatESLintConfigItem["rules"];
125
- typescriptWithTypes?: FlatESLintConfigItem["rules"];
126
128
  test?: FlatESLintConfigItem["rules"];
127
129
  vue?: FlatESLintConfigItem["rules"];
128
130
  solid?: FlatESLintConfigItem["rules"];
@@ -157,8 +159,7 @@ declare const test: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[
157
159
 
158
160
  declare const toml: ({ overrides, }?: OptionsOverrides) => FlatESLintConfigItem[];
159
161
 
160
- declare const typescript: ({ componentExts, overrides, }?: OptionsComponentExts & OptionsOverrides) => FlatESLintConfigItem[];
161
- declare const typescriptWithTypes: ({ componentExts, tsconfigPath, tsconfigRootDir, overrides, }: OptionsTypeScriptWithTypes & OptionsComponentExts & OptionsOverrides) => FlatESLintConfigItem[];
162
+ declare function typescript({ componentExts, parserOptions, overrides, }?: OptionsTypeScriptParserOptions & OptionsComponentExts & OptionsOverrides): FlatESLintConfigItem[];
162
163
 
163
164
  declare const unicorn: () => FlatESLintConfigItem[];
164
165
 
@@ -208,4 +209,4 @@ declare function recordRulesStateConfigs(configs: FlatESLintConfigItem[]): FlatE
208
209
  declare function recordRulesState(rules: FlatESLintConfigItem["rules"]): FlatESLintConfigItem["rules"];
209
210
  declare function warnUnnecessaryOffRules(): void;
210
211
 
211
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptWithTypes, combine, comments, html, ignores, imports, javascript, jsdoc, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, typescriptWithTypes, unicorn, vue, warnUnnecessaryOffRules, yaml };
212
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, Options, OptionsComponentExts, OptionsHasTypeScript, OptionsOverrides, OptionsTypeScriptParserOptions, combine, comments, html, ignores, imports, javascript, jsdoc, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/dist/index.mjs CHANGED
@@ -853,239 +853,233 @@ function warnUnnecessaryOffRules() {
853
853
  }
854
854
  }
855
855
 
856
- const typescript = ({
856
+ function typescript({
857
857
  componentExts = [],
858
+ parserOptions,
858
859
  overrides
859
- } = {}) => [
860
- {
861
- // Install the plugins without globs, so they can be configured separately.
862
- plugins: {
863
- import: pluginImport,
864
- ts: pluginTs
865
- }
866
- },
867
- {
868
- files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
869
- languageOptions: {
870
- parser: parserTs,
871
- parserOptions: {
872
- sourceType: "module"
860
+ } = {}) {
861
+ const typeAwareRules = {
862
+ "etc/no-assign-mutated-array": "error",
863
+ "etc/no-deprecated": "warn",
864
+ "etc/no-internal": "error",
865
+ "no-throw-literal": "off",
866
+ "ts/no-throw-literal": "error",
867
+ "no-implied-eval": "off",
868
+ "ts/no-implied-eval": "error",
869
+ "dot-notation": "off",
870
+ "ts/dot-notation": ["error", { allowKeywords: true }],
871
+ "no-void": ["error", { allowAsStatement: true }],
872
+ "ts/await-thenable": "error",
873
+ "ts/no-for-in-array": "error",
874
+ "ts/no-unnecessary-type-assertion": "error",
875
+ "ts/restrict-template-expressions": [
876
+ "error",
877
+ {
878
+ allowAny: true,
879
+ allowNumber: true,
880
+ allowBoolean: true
873
881
  }
874
- },
875
- settings: {
876
- "import/resolver": {
877
- node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
878
- typescript: {
879
- extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
880
- }
882
+ ],
883
+ "ts/array-type": ["error", { default: "array", readonly: "array" }],
884
+ "ts/consistent-generic-constructors": "error",
885
+ "ts/consistent-type-exports": "error",
886
+ "ts/consistent-type-assertions": [
887
+ "error",
888
+ { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
889
+ ],
890
+ "ts/prefer-nullish-coalescing": "error",
891
+ "ts/prefer-optional-chain": "error",
892
+ "ts/prefer-return-this-type": "error",
893
+ "ts/no-unnecessary-type-arguments": "error",
894
+ "ts/non-nullable-type-assertion-style": "error"
895
+ };
896
+ return [
897
+ {
898
+ // Install the plugins without globs, so they can be configured separately.
899
+ plugins: {
900
+ import: pluginImport,
901
+ ts: pluginTs,
902
+ etc: pluginEtc
881
903
  }
882
904
  },
883
- rules: {
884
- ...renameRules(
885
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
886
- "@typescript-eslint/",
887
- "ts/"
888
- ),
889
- ...renameRules(
890
- pluginTs.configs.recommended.rules,
891
- "@typescript-eslint/",
892
- "ts/"
893
- ),
894
- "import/named": "off",
895
- // TS
896
- "ts/comma-dangle": "off",
897
- "ts/brace-style": "off",
898
- "ts/comma-spacing": "off",
899
- "ts/func-call-spacing": "off",
900
- "ts/indent": "off",
901
- "ts/keyword-spacing": "off",
902
- "ts/member-delimiter-style": "off",
903
- "ts/no-extra-parens": "off",
904
- "ts/no-extra-semi": "off",
905
- "ts/quotes": "off",
906
- "ts/semi": "off",
907
- "ts/space-before-function-paren": "off",
908
- "ts/type-annotation-spacing": "off",
909
- "ts/ban-ts-comment": [
910
- "error",
911
- {
912
- minimumDescriptionLength: 0
905
+ {
906
+ files: [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)],
907
+ languageOptions: {
908
+ parser: parserTs,
909
+ parserOptions: {
910
+ sourceType: "module",
911
+ EXPERIMENTAL_useProjectService: true,
912
+ ...parserOptions
913
913
  }
914
- ],
915
- "ts/ban-types": [
916
- "error",
917
- {
918
- extendDefaults: false,
919
- types: {
920
- String: {
921
- message: "Use `string` instead.",
922
- fixWith: "string"
923
- },
924
- Number: {
925
- message: "Use `number` instead.",
926
- fixWith: "number"
927
- },
928
- Boolean: {
929
- message: "Use `boolean` instead.",
930
- fixWith: "boolean"
931
- },
932
- Symbol: {
933
- message: "Use `symbol` instead.",
934
- fixWith: "symbol"
935
- },
936
- BigInt: {
937
- message: "Use `bigint` instead.",
938
- fixWith: "bigint"
939
- },
940
- Object: {
941
- message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
942
- fixWith: "Record<PropertyKey, unknown>"
943
- },
944
- object: {
945
- message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
946
- fixWith: "Record<PropertyKey, unknown>"
947
- },
948
- Function: {
949
- message: "Use `(...args: any[]) => any` instead.",
950
- fixWith: "(...args: any[]) => any"
914
+ },
915
+ settings: {
916
+ "import/resolver": {
917
+ node: { extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"] },
918
+ typescript: {
919
+ extensions: [".js", ".jsx", ".mjs", ".ts", ".tsx", ".d.ts"]
920
+ }
921
+ }
922
+ },
923
+ rules: {
924
+ ...renameRules(
925
+ pluginTs.configs["eslint-recommended"].overrides[0].rules,
926
+ "@typescript-eslint/",
927
+ "ts/"
928
+ ),
929
+ ...renameRules(
930
+ pluginTs.configs.recommended.rules,
931
+ "@typescript-eslint/",
932
+ "ts/"
933
+ ),
934
+ "import/named": "off",
935
+ // TS
936
+ "ts/comma-dangle": "off",
937
+ "ts/brace-style": "off",
938
+ "ts/comma-spacing": "off",
939
+ "ts/func-call-spacing": "off",
940
+ "ts/indent": "off",
941
+ "ts/keyword-spacing": "off",
942
+ "ts/member-delimiter-style": "off",
943
+ "ts/no-extra-parens": "off",
944
+ "ts/no-extra-semi": "off",
945
+ "ts/quotes": "off",
946
+ "ts/semi": "off",
947
+ "ts/space-before-function-paren": "off",
948
+ "ts/type-annotation-spacing": "off",
949
+ "ts/ban-ts-comment": [
950
+ "error",
951
+ {
952
+ minimumDescriptionLength: 0
953
+ }
954
+ ],
955
+ "ts/ban-types": [
956
+ "error",
957
+ {
958
+ extendDefaults: false,
959
+ types: {
960
+ String: {
961
+ message: "Use `string` instead.",
962
+ fixWith: "string"
963
+ },
964
+ Number: {
965
+ message: "Use `number` instead.",
966
+ fixWith: "number"
967
+ },
968
+ Boolean: {
969
+ message: "Use `boolean` instead.",
970
+ fixWith: "boolean"
971
+ },
972
+ Symbol: {
973
+ message: "Use `symbol` instead.",
974
+ fixWith: "symbol"
975
+ },
976
+ BigInt: {
977
+ message: "Use `bigint` instead.",
978
+ fixWith: "bigint"
979
+ },
980
+ Object: {
981
+ message: "The `Object` type is mostly the same as `unknown`. You probably want `Record<PropertyKey, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
982
+ fixWith: "Record<PropertyKey, unknown>"
983
+ },
984
+ object: {
985
+ message: "The `object` type is hard to use. Use `Record<PropertyKey, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
986
+ fixWith: "Record<PropertyKey, unknown>"
987
+ },
988
+ Function: {
989
+ message: "Use `(...args: any[]) => any` instead.",
990
+ fixWith: "(...args: any[]) => any"
991
+ }
951
992
  }
952
993
  }
994
+ ],
995
+ "ts/consistent-type-imports": [
996
+ "error",
997
+ { prefer: "type-imports", disallowTypeAnnotations: false }
998
+ ],
999
+ "ts/consistent-type-definitions": ["error", "interface"],
1000
+ "ts/consistent-indexed-object-style": ["error", "record"],
1001
+ "ts/prefer-ts-expect-error": "error",
1002
+ "ts/no-require-imports": "error",
1003
+ "ts/method-signature-style": ["error", "property"],
1004
+ // Override JS
1005
+ "no-useless-constructor": "off",
1006
+ "no-invalid-this": "off",
1007
+ "ts/no-invalid-this": "error",
1008
+ "no-redeclare": "off",
1009
+ "ts/no-redeclare": "error",
1010
+ "no-use-before-define": "off",
1011
+ "ts/no-use-before-define": [
1012
+ "error",
1013
+ { functions: false, classes: false, variables: true }
1014
+ ],
1015
+ "object-curly-spacing": "off",
1016
+ "space-before-blocks": "off",
1017
+ "ts/space-before-blocks": "off",
1018
+ "space-before-function-paren": "off",
1019
+ "no-dupe-class-members": "off",
1020
+ "ts/no-dupe-class-members": "error",
1021
+ "no-loss-of-precision": "off",
1022
+ "ts/no-loss-of-precision": "error",
1023
+ "lines-between-class-members": "off",
1024
+ "ts/lines-between-class-members": [
1025
+ "error",
1026
+ "always",
1027
+ { exceptAfterSingleLine: true }
1028
+ ],
1029
+ // so1ve
1030
+ "so1ve/no-inline-type-import": "error",
1031
+ // off
1032
+ "ts/camelcase": "off",
1033
+ "ts/explicit-function-return-type": "off",
1034
+ "ts/explicit-member-accessibility": "off",
1035
+ "ts/no-explicit-any": "off",
1036
+ "ts/no-parameter-properties": "off",
1037
+ "ts/no-empty-interface": "off",
1038
+ "ts/ban-ts-ignore": "off",
1039
+ "ts/no-empty-function": "off",
1040
+ "ts/no-non-null-assertion": "off",
1041
+ "ts/explicit-module-boundary-types": "off",
1042
+ "ts/triple-slash-reference": "off",
1043
+ "ts/prefer-for-of": "error",
1044
+ "ts/no-duplicate-enum-values": "error",
1045
+ "ts/no-non-null-asserted-nullish-coalescing": "error",
1046
+ // handled by unused-imports/no-unused-imports
1047
+ "ts/no-unused-vars": "off",
1048
+ ...typeAwareRules,
1049
+ ...overrides
1050
+ }
1051
+ },
1052
+ {
1053
+ files: [GLOB_MARKDOWN_CODE],
1054
+ languageOptions: {
1055
+ parser: parserTs,
1056
+ parserOptions: {
1057
+ sourceType: "module"
953
1058
  }
954
- ],
955
- "ts/consistent-type-imports": [
956
- "error",
957
- { prefer: "type-imports", disallowTypeAnnotations: false }
958
- ],
959
- "ts/consistent-type-definitions": ["error", "interface"],
960
- "ts/consistent-indexed-object-style": ["error", "record"],
961
- "ts/prefer-ts-expect-error": "error",
962
- "ts/no-require-imports": "error",
963
- "ts/method-signature-style": ["error", "property"],
964
- // Override JS
965
- "no-useless-constructor": "off",
966
- "no-invalid-this": "off",
967
- "ts/no-invalid-this": "error",
968
- "no-redeclare": "off",
969
- "ts/no-redeclare": "error",
970
- "no-use-before-define": "off",
971
- "ts/no-use-before-define": [
972
- "error",
973
- { functions: false, classes: false, variables: true }
974
- ],
975
- "object-curly-spacing": "off",
976
- "space-before-blocks": "off",
977
- "ts/space-before-blocks": "off",
978
- "space-before-function-paren": "off",
979
- "no-dupe-class-members": "off",
980
- "ts/no-dupe-class-members": "error",
981
- "no-loss-of-precision": "off",
982
- "ts/no-loss-of-precision": "error",
983
- "lines-between-class-members": "off",
984
- "ts/lines-between-class-members": [
985
- "error",
986
- "always",
987
- { exceptAfterSingleLine: true }
988
- ],
989
- // so1ve
990
- "so1ve/no-inline-type-import": "error",
991
- // off
992
- "ts/camelcase": "off",
993
- "ts/explicit-function-return-type": "off",
994
- "ts/explicit-member-accessibility": "off",
995
- "ts/no-explicit-any": "off",
996
- "ts/no-parameter-properties": "off",
997
- "ts/no-empty-interface": "off",
998
- "ts/ban-ts-ignore": "off",
999
- "ts/no-empty-function": "off",
1000
- "ts/no-non-null-assertion": "off",
1001
- "ts/explicit-module-boundary-types": "off",
1002
- "ts/triple-slash-reference": "off",
1003
- "ts/prefer-for-of": "error",
1004
- "ts/no-duplicate-enum-values": "error",
1005
- "ts/no-non-null-asserted-nullish-coalescing": "error",
1006
- // handled by unused-imports/no-unused-imports
1007
- "ts/no-unused-vars": "off",
1008
- ...overrides
1009
- }
1010
- },
1011
- {
1012
- files: ["**/*.d.ts"],
1013
- rules: {
1014
- "eslint-comments/no-unlimited-disable": "off",
1015
- "import/no-duplicates": "off",
1016
- "unused-imports/no-unused-vars": "off"
1017
- }
1018
- },
1019
- {
1020
- files: ["**/*.js", "**/*.cjs"],
1021
- rules: {
1022
- "ts/no-require-imports": "off",
1023
- "ts/no-var-requires": "off"
1024
- }
1025
- }
1026
- ];
1027
- const typescriptWithTypes = ({
1028
- componentExts = [],
1029
- tsconfigPath,
1030
- tsconfigRootDir = process.cwd(),
1031
- overrides = {}
1032
- }) => [
1033
- {
1034
- files: [
1035
- GLOB_TS,
1036
- GLOB_TSX,
1037
- ...componentExts.map((ext) => `**/*.${ext}`),
1038
- `!${GLOB_MARKDOWN}/*.*`
1039
- ],
1040
- plugins: {
1041
- etc: pluginEtc
1059
+ },
1060
+ rules: {
1061
+ ...Object.fromEntries(
1062
+ Object.keys(typeAwareRules).map((k) => [k, "off"])
1063
+ )
1064
+ }
1042
1065
  },
1043
- languageOptions: {
1044
- parser: parserTs,
1045
- parserOptions: {
1046
- project: [tsconfigPath],
1047
- tsconfigRootDir,
1048
- EXPERIMENTAL_useProjectService: true
1066
+ {
1067
+ files: ["**/*.d.ts"],
1068
+ rules: {
1069
+ "eslint-comments/no-unlimited-disable": "off",
1070
+ "import/no-duplicates": "off",
1071
+ "unused-imports/no-unused-vars": "off"
1049
1072
  }
1050
1073
  },
1051
- rules: {
1052
- "etc/no-assign-mutated-array": "error",
1053
- "etc/no-deprecated": "warn",
1054
- "etc/no-internal": "error",
1055
- "no-throw-literal": "off",
1056
- "ts/no-throw-literal": "error",
1057
- "no-implied-eval": "off",
1058
- "ts/no-implied-eval": "error",
1059
- "dot-notation": "off",
1060
- "ts/dot-notation": ["error", { allowKeywords: true }],
1061
- "no-void": ["error", { allowAsStatement: true }],
1062
- "ts/await-thenable": "error",
1063
- "ts/no-for-in-array": "error",
1064
- "ts/no-unnecessary-type-assertion": "error",
1065
- "ts/restrict-template-expressions": [
1066
- "error",
1067
- {
1068
- allowAny: true,
1069
- allowNumber: true,
1070
- allowBoolean: true
1071
- }
1072
- ],
1073
- "ts/array-type": ["error", { default: "array", readonly: "array" }],
1074
- "ts/consistent-generic-constructors": "error",
1075
- "ts/consistent-type-exports": "error",
1076
- "ts/consistent-type-assertions": [
1077
- "error",
1078
- { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }
1079
- ],
1080
- "ts/prefer-nullish-coalescing": "error",
1081
- "ts/prefer-optional-chain": "error",
1082
- "ts/prefer-return-this-type": "error",
1083
- "ts/no-unnecessary-type-arguments": "error",
1084
- "ts/non-nullable-type-assertion-style": "error",
1085
- ...overrides
1074
+ {
1075
+ files: ["**/*.js", "**/*.cjs"],
1076
+ rules: {
1077
+ "ts/no-require-imports": "off",
1078
+ "ts/no-var-requires": "off"
1079
+ }
1086
1080
  }
1087
- }
1088
- ];
1081
+ ];
1082
+ }
1089
1083
 
1090
1084
  const unicorn = () => [
1091
1085
  {
@@ -1408,15 +1402,6 @@ function so1ve(options = {}, ...userConfigs) {
1408
1402
  overrides: overrides.typescript
1409
1403
  })
1410
1404
  );
1411
- if (typeof enableTypeScript !== "boolean") {
1412
- configs.push(
1413
- typescriptWithTypes({
1414
- ...enableTypeScript,
1415
- componentExts,
1416
- overrides: overrides.typescriptWithTypes
1417
- })
1418
- );
1419
- }
1420
1405
  }
1421
1406
  if ((_a = options.test) != null ? _a : true) {
1422
1407
  configs.push(
@@ -1479,4 +1464,4 @@ function so1ve(options = {}, ...userConfigs) {
1479
1464
  return merged;
1480
1465
  }
1481
1466
 
1482
- export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, combine, comments, html, ignores, imports, javascript, jsdoc, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, typescriptWithTypes, unicorn, vue, warnUnnecessaryOffRules, yaml };
1467
+ export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DTS, GLOB_ESLINTRC, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_PACKAGEJSON, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_YAML, combine, comments, html, ignores, imports, javascript, jsdoc, jsonc, mdx, node, onlyError, promise, recordRulesState, recordRulesStateConfigs, renameRules, so1ve, solid, sortImports, test, toml, typescript, unicorn, vue, warnUnnecessaryOffRules, yaml };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@so1ve/eslint-config",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve/)",
5
5
  "description": "Ray's eslint config.",
6
6
  "keywords": [
@@ -71,8 +71,8 @@
71
71
  "toml-eslint-parser": "^0.6.0",
72
72
  "vue-eslint-parser": "^9.3.1",
73
73
  "yaml-eslint-parser": "^1.2.2",
74
- "@so1ve/eslint-plugin": "1.0.0-alpha.3",
75
- "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.3"
74
+ "@so1ve/eslint-plugin-sort-imports": "1.0.0-alpha.4",
75
+ "@so1ve/eslint-plugin": "1.0.0-alpha.4"
76
76
  },
77
77
  "devDependencies": {
78
78
  "eslint": "^8.46.0"