@jsse/eslint-config 0.3.7 → 0.4.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 (44) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cli.js +3 -3
  3. package/dist/esm/config-fns.d.ts +109 -34
  4. package/dist/esm/config-fns.js +111 -35
  5. package/dist/esm/configs/{comments.d.ts → de-morgan.d.ts} +1 -1
  6. package/dist/esm/configs/de-morgan.js +9 -0
  7. package/dist/esm/configs/eslint-comments.d.ts +2 -0
  8. package/dist/esm/configs/{comments.js → eslint-comments.js} +1 -1
  9. package/dist/esm/configs/gql.d.ts +2 -2
  10. package/dist/esm/configs/markdown.js +1 -1
  11. package/dist/esm/configs/prettier.d.ts +2 -2
  12. package/dist/esm/configs/react.d.ts +3 -3
  13. package/dist/esm/configs/stylistic.js +1 -1
  14. package/dist/esm/configs/ts/parser.d.ts +2 -2
  15. package/dist/esm/configs/ts/parser.js +7 -5
  16. package/dist/esm/configs/ts/typescript-rules.d.ts +9 -4
  17. package/dist/esm/configs/ts/typescript-rules.js +26 -62
  18. package/dist/esm/configs/ts/typescript.js +56 -43
  19. package/dist/esm/define-config.d.ts +3 -3
  20. package/dist/esm/define-config.js +38 -28
  21. package/dist/esm/fixable.d.ts +2 -1
  22. package/dist/esm/fixable.js +3 -395
  23. package/dist/esm/generated/fixable-rules-map.d.ts +2 -0
  24. package/dist/esm/generated/fixable-rules-map.js +436 -0
  25. package/dist/esm/generated/version.d.ts +1 -1
  26. package/dist/esm/generated/version.js +1 -1
  27. package/dist/esm/index.d.ts +1 -1
  28. package/dist/esm/index.js +0 -1
  29. package/dist/esm/lager.d.ts +1 -1
  30. package/dist/esm/lager.js +1 -1
  31. package/dist/esm/plugins-all.d.ts +11 -8
  32. package/dist/esm/plugins-all.js +99 -10
  33. package/dist/esm/plugins.d.ts +1 -0
  34. package/dist/esm/plugins.js +4 -1
  35. package/dist/esm/presets.d.ts +16 -0
  36. package/dist/esm/presets.js +96 -1
  37. package/dist/esm/types.d.ts +34 -22
  38. package/dist/esm/utils.d.ts +5 -5
  39. package/dist/esm/utils.js +1 -1
  40. package/dist/index.d.ts +7404 -6303
  41. package/dist/index.js +289 -227
  42. package/package.json +20 -27
  43. package/dist/esm/plugindex.d.ts +0 -7
  44. package/dist/esm/plugindex.js +0 -60
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @jsse/eslint-config
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7751e66: removed tailwind support
8
+
9
+ ### Patch Changes
10
+
11
+ - e15fd48: re-orged several things. fixed type aware lints
12
+
3
13
  ## 0.3.7
4
14
 
5
15
  ### Patch Changes
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/cli.ts
2
- import fs from "node:fs";
3
- import process2 from "node:process";
2
+ import fs from "fs";
3
+ import process2 from "process";
4
4
 
5
5
  // node_modules/.pnpm/cac@6.7.14/node_modules/cac/dist/index.mjs
6
6
  import { EventEmitter } from "events";
@@ -588,7 +588,7 @@ var CAC = class extends EventEmitter {
588
588
  var cac = (name = "") => new CAC(name);
589
589
 
590
590
  // src/generated/version.ts
591
- var VERSION = "0.3.7";
591
+ var VERSION = "0.4.0";
592
592
 
593
593
  // src/cli.ts
594
594
  var cli = cac("jsselint");
@@ -1,40 +1,116 @@
1
1
  import { reactHooks } from "./configs/react.js";
2
- export declare function configFunctions(): {
3
- antfu: import("./types.js").EslintConfigFn<{
4
- topLevelFunction: "error" | "off";
5
- }>;
6
- command: import("./types.js").EslintConfigFn;
7
- comments: import("./types.js").EslintConfigFn;
8
- ignores: import("./types.js").EslintConfigFn;
9
- imports: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic>;
10
- javascript: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides & {
11
- reportUnusedDisableDirectives?: boolean;
12
- }>;
13
- jsdoc: import("./types.js").EslintConfigFn;
14
- jsonc: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic & import("./types.js").OptionsOverrides>;
15
- markdown: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides>;
16
- n: import("./types.js").EslintConfigFn;
17
- noOnlyTests: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
18
- perfectionist: import("./types.js").EslintConfigFn;
19
- prettier: import("./types.js").EslintConfigFn;
20
- react: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact>;
21
- reactHooks: typeof reactHooks;
22
- sortPackageJson: import("./types.js").EslintConfigFn;
23
- sortTsconfig: import("./types.js").EslintConfigFn<{
24
- extendTsconfigGlobs?: string[];
25
- }>;
26
- stylistic: import("./types.js").EslintConfigFn<import("./types.js").StylisticConfig>;
27
- tailwind: import("./types.js").EslintConfigFn<Partial<import("./types.js").TailwindEslintSettings>>;
28
- toml: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsFiles & import("./types.js").OptionsStylistic>;
29
- tsdoc: import("./types.js").EslintConfigFn;
30
- typescript: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact & import("./types.js").OptionsPrefix>;
31
- unicorn: import("./types.js").EslintConfigFn;
32
- vitest: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
33
- yml: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsStylistic & import("./types.js").OptionsFiles>;
2
+ export declare const CONFIGS_MAPPING: {
3
+ antfu: {
4
+ fn: import("./types.js").EslintConfigFn<{
5
+ topLevelFunction: "error" | "off";
6
+ }>;
7
+ typeName: string;
8
+ };
9
+ command: {
10
+ fn: import("./types.js").EslintConfigFn;
11
+ typeName: string;
12
+ };
13
+ "de-morgan": {
14
+ fn: import("./types.js").EslintConfigFn;
15
+ typeName: string;
16
+ };
17
+ "eslint-comments": {
18
+ fn: import("./types.js").EslintConfigFn;
19
+ typeName: string;
20
+ };
21
+ ignores: {
22
+ fn: import("./types.js").EslintConfigFn;
23
+ typeName: string;
24
+ };
25
+ imports: {
26
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic>;
27
+ typeName: string;
28
+ };
29
+ javascript: {
30
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides & {
31
+ reportUnusedDisableDirectives?: boolean;
32
+ }>;
33
+ typeName: string;
34
+ };
35
+ jsdoc: {
36
+ fn: import("./types.js").EslintConfigFn;
37
+ typeName: string;
38
+ };
39
+ jsonc: {
40
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsStylistic & import("./types.js").OptionsOverrides>;
41
+ typeName: string;
42
+ };
43
+ markdown: {
44
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides>;
45
+ typeName: string;
46
+ };
47
+ n: {
48
+ fn: import("./types.js").EslintConfigFn;
49
+ typeName: string;
50
+ };
51
+ "no-only-tests": {
52
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
53
+ typeName: string;
54
+ };
55
+ perfectionist: {
56
+ fn: import("./types.js").EslintConfigFn;
57
+ typeName: string;
58
+ };
59
+ prettier: {
60
+ fn: import("./types.js").EslintConfigFn;
61
+ typeName: string;
62
+ };
63
+ react: {
64
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact>;
65
+ typeName: string;
66
+ };
67
+ "react-hooks": {
68
+ fn: typeof reactHooks;
69
+ typeName: string;
70
+ };
71
+ "sort-package-json": {
72
+ fn: import("./types.js").EslintConfigFn;
73
+ typeName: string;
74
+ };
75
+ "sort-tsconfig": {
76
+ fn: import("./types.js").EslintConfigFn<{
77
+ extendTsconfigGlobs?: string[];
78
+ }>;
79
+ typeName: string;
80
+ };
81
+ stylistic: {
82
+ fn: import("./types.js").EslintConfigFn<import("./types.js").StylisticConfig>;
83
+ typeName: string;
84
+ };
85
+ toml: {
86
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsFiles & import("./types.js").OptionsStylistic>;
87
+ typeName: string;
88
+ };
89
+ tsdoc: {
90
+ fn: import("./types.js").EslintConfigFn;
91
+ typeName: string;
92
+ };
93
+ typescript: {
94
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsComponentExts & import("./types.js").OptionsOverrides & import("./types.js").OptionsTypeScriptWithTypes & import("./types.js").OptionsTypeScriptParserOptions & import("./types.js").OptionsReact & import("./types.js").OptionsPrefix>;
95
+ typeName: string;
96
+ };
97
+ unicorn: {
98
+ fn: import("./types.js").EslintConfigFn;
99
+ typeName: string;
100
+ };
101
+ vitest: {
102
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsIsInEditor & import("./types.js").OptionsOverrides>;
103
+ typeName: string;
104
+ };
105
+ yml: {
106
+ fn: import("./types.js").EslintConfigFn<import("./types.js").OptionsOverrides & import("./types.js").OptionsStylistic & import("./types.js").OptionsFiles>;
107
+ typeName: string;
108
+ };
34
109
  };
35
110
  export { antfu } from "./configs/antfu.js";
36
111
  export { command } from "./configs/command.js";
37
- export { comments } from "./configs/comments.js";
112
+ export { deMorgan } from "./configs/de-morgan.js";
113
+ export { eslintComments } from "./configs/eslint-comments.js";
38
114
  export { ignores } from "./configs/ignores.js";
39
115
  export { imports } from "./configs/imports.js";
40
116
  export { javascript } from "./configs/javascript.js";
@@ -49,7 +125,6 @@ export { react, reactHooks } from "./configs/react.js";
49
125
  export { sortPackageJson } from "./configs/sort-package-json.js";
50
126
  export { sortTsconfig } from "./configs/sort-tsconfig.js";
51
127
  export { stylistic } from "./configs/stylistic.js";
52
- export { tailwind } from "./configs/tailwind.js";
53
128
  export { toml } from "./configs/toml.js";
54
129
  export { typescript } from "./configs/ts/typescript.js";
55
130
  export { tsdoc } from "./configs/tsdoc.js";
@@ -1,6 +1,7 @@
1
1
  import { antfu } from "./configs/antfu.js";
2
2
  import { command } from "./configs/command.js";
3
- import { comments } from "./configs/comments.js";
3
+ import { deMorgan } from "./configs/de-morgan.js";
4
+ import { eslintComments } from "./configs/eslint-comments.js";
4
5
  import { ignores } from "./configs/ignores.js";
5
6
  import { imports } from "./configs/imports.js";
6
7
  import { javascript } from "./configs/javascript.js";
@@ -15,47 +16,123 @@ import { react, reactHooks } from "./configs/react.js";
15
16
  import { sortPackageJson } from "./configs/sort-package-json.js";
16
17
  import { sortTsconfig } from "./configs/sort-tsconfig.js";
17
18
  import { stylistic } from "./configs/stylistic.js";
18
- import { tailwind } from "./configs/tailwind.js";
19
19
  import { toml } from "./configs/toml.js";
20
20
  import { typescript } from "./configs/ts/typescript.js";
21
21
  import { tsdoc } from "./configs/tsdoc.js";
22
22
  import { unicorn } from "./configs/unicorn.js";
23
23
  import { vitest } from "./configs/vitest.js";
24
24
  import { yml } from "./configs/yml.js";
25
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
26
- export function configFunctions() {
27
- // @keep-sorted
28
- return {
29
- antfu,
30
- command,
31
- comments,
32
- ignores,
33
- imports,
34
- javascript,
35
- jsdoc,
36
- jsonc,
37
- markdown,
38
- n,
39
- noOnlyTests,
40
- perfectionist,
41
- prettier,
42
- react,
43
- reactHooks,
44
- sortPackageJson,
45
- sortTsconfig,
46
- stylistic,
47
- tailwind,
48
- toml,
49
- tsdoc,
50
- typescript,
51
- unicorn,
52
- vitest,
53
- yml,
54
- };
55
- }
25
+ export const CONFIGS_MAPPING = {
26
+ antfu: {
27
+ fn: antfu,
28
+ typeName: "AntfuRuleOptions",
29
+ },
30
+ command: {
31
+ fn: command,
32
+ typeName: "CommandRuleOptions",
33
+ },
34
+ "de-morgan": {
35
+ fn: deMorgan,
36
+ typeName: "DeMorganRuleOptions",
37
+ },
38
+ "eslint-comments": {
39
+ fn: eslintComments,
40
+ typeName: "EslintCommentsRuleOptions",
41
+ },
42
+ ignores: {
43
+ fn: ignores,
44
+ typeName: "IgnoresRuleOptions",
45
+ },
46
+ imports: {
47
+ fn: imports,
48
+ typeName: "ImportsRuleOptions",
49
+ },
50
+ javascript: {
51
+ fn: javascript,
52
+ typeName: "JavascriptRuleOptions",
53
+ },
54
+ jsdoc: {
55
+ fn: jsdoc,
56
+ typeName: "JsdocRuleOptions",
57
+ },
58
+ jsonc: {
59
+ fn: jsonc,
60
+ typeName: "JsoncRuleOptions",
61
+ },
62
+ markdown: {
63
+ fn: markdown,
64
+ typeName: "MarkdownRuleOptions",
65
+ },
66
+ n: {
67
+ fn: n,
68
+ typeName: "NRuleOptions",
69
+ },
70
+ "no-only-tests": {
71
+ fn: noOnlyTests,
72
+ typeName: "NoOnlyTestsRuleOptions",
73
+ },
74
+ perfectionist: {
75
+ fn: perfectionist,
76
+ typeName: "PerfectionistRuleOptions",
77
+ },
78
+ prettier: {
79
+ fn: prettier,
80
+ typeName: "PrettierRuleOptions",
81
+ },
82
+ react: {
83
+ fn: react,
84
+ typeName: "ReactRuleOptions",
85
+ },
86
+ "react-hooks": {
87
+ fn: reactHooks,
88
+ typeName: "ReactHooksRuleOptions",
89
+ },
90
+ "sort-package-json": {
91
+ fn: sortPackageJson,
92
+ typeName: "SortPackageJsonRuleOptions",
93
+ },
94
+ "sort-tsconfig": {
95
+ fn: sortTsconfig,
96
+ typeName: "SortTsconfigRuleOptions",
97
+ },
98
+ stylistic: {
99
+ fn: stylistic,
100
+ typeName: "StylisticRuleOptions",
101
+ },
102
+ toml: {
103
+ fn: toml,
104
+ typeName: "TomlRuleOptions",
105
+ },
106
+ tsdoc: {
107
+ fn: tsdoc,
108
+ typeName: "TsdocRuleOptions",
109
+ },
110
+ // deprecated
111
+ // tailwind: {
112
+ // typeName: "TailwindRuleOptions",
113
+ // fn: tailwind,
114
+ // },
115
+ typescript: {
116
+ fn: typescript,
117
+ typeName: "TypescriptRuleOptions",
118
+ },
119
+ unicorn: {
120
+ fn: unicorn,
121
+ typeName: "UnicornRuleOptions",
122
+ },
123
+ vitest: {
124
+ fn: vitest,
125
+ typeName: "VitestRuleOptions",
126
+ },
127
+ yml: {
128
+ fn: yml,
129
+ typeName: "YmlRuleOptions",
130
+ },
131
+ };
56
132
  export { antfu } from "./configs/antfu.js";
57
133
  export { command } from "./configs/command.js";
58
- export { comments } from "./configs/comments.js";
134
+ export { deMorgan } from "./configs/de-morgan.js";
135
+ export { eslintComments } from "./configs/eslint-comments.js";
59
136
  export { ignores } from "./configs/ignores.js";
60
137
  export { imports } from "./configs/imports.js";
61
138
  export { javascript } from "./configs/javascript.js";
@@ -70,7 +147,6 @@ export { react, reactHooks } from "./configs/react.js";
70
147
  export { sortPackageJson } from "./configs/sort-package-json.js";
71
148
  export { sortTsconfig } from "./configs/sort-tsconfig.js";
72
149
  export { stylistic } from "./configs/stylistic.js";
73
- export { tailwind } from "./configs/tailwind.js";
74
150
  export { toml } from "./configs/toml.js";
75
151
  export { typescript } from "./configs/ts/typescript.js";
76
152
  export { tsdoc } from "./configs/tsdoc.js";
@@ -1,2 +1,2 @@
1
1
  import type { EslintConfigFn } from "../types.js";
2
- export declare const comments: EslintConfigFn;
2
+ export declare const deMorgan: EslintConfigFn;
@@ -0,0 +1,9 @@
1
+ import { pluginDeMorgan } from "../plugins.js";
2
+ export const deMorgan = async () => {
3
+ return [
4
+ {
5
+ ...pluginDeMorgan.configs.recommended,
6
+ name: "jsse/de-morgan",
7
+ },
8
+ ];
9
+ };
@@ -0,0 +1,2 @@
1
+ import type { EslintConfigFn } from "../types.js";
2
+ export declare const eslintComments: EslintConfigFn;
@@ -1,5 +1,5 @@
1
1
  import { pluginEslintComments } from "../plugins.js";
2
- export const comments = async () => [
2
+ export const eslintComments = async () => [
3
3
  {
4
4
  name: "jsse/eslint-comments",
5
5
  plugins: {
@@ -1,2 +1,2 @@
1
- import type { TypedFlatConfigItem } from "src/types.js";
2
- export declare function gql(): TypedFlatConfigItem[];
1
+ import type { Config } from "src/types.js";
2
+ export declare function gql(): Config[];
@@ -18,7 +18,7 @@ export const markdown = async (options) => {
18
18
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
19
19
  pluginMarkdown.processors.markdown,
20
20
  processorPassThrough,
21
- ].filter((processor) => processor !== undefined));
21
+ ]);
22
22
  return [
23
23
  {
24
24
  name: "jsse/markdown/setup",
@@ -1,7 +1,7 @@
1
- import type { EslintConfigFn, TypedFlatConfigItem } from "../types.js";
1
+ import type { Config, EslintConfigFn } from "../types.js";
2
2
  /**
3
3
  * Copied from https://raw.githubusercontent.com/prettier/eslint-config-prettier/main/index.js
4
4
  * Main difference is we exclude rules we don't care about.... (flow/babel/etc)
5
5
  */
6
- export declare function eslintConfigPrettierRules(): TypedFlatConfigItem["rules"];
6
+ export declare function eslintConfigPrettierRules(): Config["rules"];
7
7
  export declare const prettier: EslintConfigFn;
@@ -1,6 +1,6 @@
1
- import type { EslintConfigFn, OptionsComponentExts, OptionsOverrides, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from "../types.js";
2
- export declare function reactRules(): TypedFlatConfigItem["rules"];
3
- export declare function reactHooks(): Promise<TypedFlatConfigItem[]>;
1
+ import type { Config, EslintConfigFn, OptionsComponentExts, OptionsOverrides, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../types.js";
2
+ export declare function reactRules(): Config["rules"];
3
+ export declare function reactHooks(): Promise<Config[]>;
4
4
  type ReactOptions = OptionsComponentExts & OptionsOverrides & OptionsTypeScriptWithTypes & OptionsTypeScriptParserOptions & OptionsReact;
5
5
  export declare const react: EslintConfigFn<ReactOptions>;
6
6
  export {};
@@ -1,5 +1,5 @@
1
1
  import { importPluginStylistic } from "../plugins.js";
2
- function jsxStylistic({ indent, }) {
2
+ function jsxStylistic({ indent }) {
3
3
  return {
4
4
  "@stylistic/jsx-curly-brace-presence": [
5
5
  "error",
@@ -1,7 +1,7 @@
1
- import type { OptionsComponentExts, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes, TypedFlatConfigItem } from "../../types.js";
1
+ import type { Config, OptionsComponentExts, OptionsReact, OptionsTypeScriptParserOptions, OptionsTypeScriptWithTypes } from "../../types.js";
2
2
  export type TsParserOptions = OptionsComponentExts & OptionsTypeScriptParserOptions & OptionsTypeScriptWithTypes & OptionsReact & {
3
3
  name?: string;
4
4
  };
5
- export declare function typescriptParser(options: TsParserOptions): TypedFlatConfigItem & {
5
+ export declare function typescriptParser(options: TsParserOptions): Config & {
6
6
  name: string;
7
7
  };
@@ -1,5 +1,5 @@
1
1
  import process from "node:process";
2
- import { debug } from "src/lager.js";
2
+ import { dbg } from "src/lager.js";
3
3
  import { GLOB_MARKDOWN, GLOB_TS, GLOB_TSX } from "../../globs.js";
4
4
  import { parserTs } from "../../plugins.js";
5
5
  function autoUseParserService(options) {
@@ -17,12 +17,13 @@ export function typescriptParser(options) {
17
17
  const { componentExts = [], filesTypeAware: files = [GLOB_TS, GLOB_TSX], ignoresTypeAware: ignores = [GLOB_MARKDOWN], name, parserOptions: parserOptionsOverride = {}, react, tsconfig, useProjectService = autoUseParserService(options), } = options;
18
18
  const typeAware = !!tsconfig;
19
19
  if (useProjectService) {
20
- debug("ts parser-options using `projectService`project service");
20
+ dbg("ts parser-options using `projectService`project service");
21
21
  return {
22
22
  files,
23
- ...(ignores ? { ignores } : {}),
23
+ ...(ignores.length > 0 ? { ignores } : {}),
24
24
  languageOptions: {
25
25
  parser: parserTs,
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
26
27
  parserOptions: {
27
28
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
28
29
  jsxPragma: react ? "React" : undefined,
@@ -44,12 +45,13 @@ export function typescriptParser(options) {
44
45
  name: name ?? `jsse/typescript/${typeAware ? "type-aware-parser" : "parser"}`,
45
46
  };
46
47
  }
47
- debug("ts parser-options NOT using `projectService`project service - using `project`");
48
+ dbg("ts parser-options NOT using `projectService`project service - using `project`");
48
49
  return {
49
50
  files,
50
- ...(ignores ? { ignores } : {}),
51
+ ...(ignores.length > 0 ? { ignores } : {}),
51
52
  languageOptions: {
52
53
  parser: parserTs,
54
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
53
55
  parserOptions: {
54
56
  extraFileExtensions: componentExts.map((ext) => `.${ext}`),
55
57
  jsxPragma: react ? "React" : undefined,
@@ -1,6 +1,11 @@
1
- import type { TypedFlatConfigItem } from "../../types.js";
2
- export declare function typescriptRulesTypeAware(): TypedFlatConfigItem["rules"];
3
- export declare function typescriptRulesTypeOblivious(): TypedFlatConfigItem["rules"];
1
+ import type { Config } from "../../types.js";
2
+ export declare function typescriptRulesTypeAware(props?: {
3
+ strict?: boolean;
4
+ }): Config["rules"];
5
+ export declare function typescriptRulesTypeOblivious(props?: {
6
+ strict?: boolean;
7
+ }): Config["rules"];
4
8
  export declare function typescriptRules(props?: {
5
9
  typeAware: boolean;
6
- }): TypedFlatConfigItem["rules"];
10
+ strict: boolean;
11
+ }): Config["rules"];
@@ -1,5 +1,19 @@
1
- export function typescriptRulesTypeAware() {
1
+ /* eslint-disable perfectionist/sort-objects */
2
+ import tseslint, {} from "typescript-eslint";
3
+ import { dbg } from "../../lager.js";
4
+ const extractRules = (configs) => {
5
+ const rules = configs
6
+ .filter((config) => config.rules !== undefined)
7
+ .map((config) => config.rules ?? {});
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
9
+ return Object.assign({}, ...rules);
10
+ };
11
+ export function typescriptRulesTypeAware(props) {
12
+ const tsRecomendedRulesTypeChecked = props?.strict
13
+ ? extractRules(tseslint.configs.strictTypeChecked)
14
+ : extractRules(tseslint.configs.recommendedTypeChecked);
2
15
  return {
16
+ ...tsRecomendedRulesTypeChecked,
3
17
  "@typescript-eslint/await-thenable": "error",
4
18
  "@typescript-eslint/no-for-in-array": "error",
5
19
  "no-implied-eval": "off",
@@ -116,8 +130,12 @@ export function typescriptRulesTypeAware() {
116
130
  ],
117
131
  };
118
132
  }
119
- export function typescriptRulesTypeOblivious() {
133
+ export function typescriptRulesTypeOblivious(props) {
134
+ const tseslintBaseRules = props?.strict
135
+ ? extractRules(tseslint.configs.strict)
136
+ : extractRules(tseslint.configs.recommended);
120
137
  return {
138
+ ...tseslintBaseRules,
121
139
  eqeqeq: "error",
122
140
  camelcase: "off",
123
141
  yoda: "error",
@@ -140,61 +158,6 @@ export function typescriptRulesTypeOblivious() {
140
158
  },
141
159
  ],
142
160
  "@typescript-eslint/adjacent-overload-signatures": "error",
143
- // "@typescript-eslint/ban-types": [
144
- // "warn",
145
- // {
146
- // extendDefaults: false,
147
- // types: {
148
- // String: {
149
- // message: 'Use "string" instead',
150
- // fixWith: "string",
151
- // },
152
- // Boolean: {
153
- // message: 'Use "boolean" instead',
154
- // fixWith: "boolean",
155
- // },
156
- // Number: {
157
- // message: 'Use "number" instead',
158
- // fixWith: "number",
159
- // },
160
- // BigInt: {
161
- // message: "Use `bigint` instead.",
162
- // fixWith: "bigint",
163
- // },
164
- // Object: {
165
- // message:
166
- // "The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848",
167
- // fixWith: "Record<string, unknown>",
168
- // },
169
- // object: {
170
- // message:
171
- // "The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848",
172
- // fixWith: "Record<string, unknown>",
173
- // },
174
- // Symbol: {
175
- // message: 'Use "symbol" instead',
176
- // fixWith: "symbol",
177
- // },
178
- // Function: {
179
- // message:
180
- // 'The "Function" type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with "new".\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.',
181
- // },
182
- // // eslint-disable-next-line @typescript-eslint/naming-convention
183
- // "{}": {
184
- // message:
185
- // "The `{}` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead.",
186
- // fixWith: "Record<string, unknown>",
187
- // },
188
- // // eslint-disable-next-line @typescript-eslint/naming-convention
189
- // "[]": "Don't use the empty array type `[]`. It only allows empty arrays. Use `SomeType[]` instead.",
190
- // // eslint-disable-next-line @typescript-eslint/naming-convention
191
- // "[[]]":
192
- // "Don't use `[[]]`. It only allows an array with a single element which is an empty array. Use `SomeType[][]` instead.",
193
- // // eslint-disable-next-line @typescript-eslint/naming-convention
194
- // "[[[]]]": "Don't use `[[[]]]`. Use `SomeType[][][]` instead.",
195
- // },
196
- // },
197
- // ],
198
161
  "@typescript-eslint/consistent-type-assertions": "error",
199
162
  "@typescript-eslint/consistent-type-definitions": ["error", "type"],
200
163
  "@typescript-eslint/member-ordering": [
@@ -404,12 +367,13 @@ export function typescriptRulesTypeOblivious() {
404
367
  };
405
368
  }
406
369
  export function typescriptRules(props) {
407
- const { typeAware } = props ?? {};
408
- if (typeAware === true) {
370
+ const normalized = { typeAware: false, strict: false, ...props };
371
+ dbg("building typescript rules: %O", normalized);
372
+ if (normalized.typeAware) {
409
373
  return {
410
- ...typescriptRulesTypeOblivious(),
411
- ...typescriptRulesTypeAware(),
374
+ ...typescriptRulesTypeOblivious({ strict: normalized.strict }),
375
+ ...typescriptRulesTypeAware({ strict: normalized.strict }),
412
376
  };
413
377
  }
414
- return typescriptRulesTypeOblivious();
378
+ return typescriptRulesTypeOblivious({ strict: normalized.strict });
415
379
  }