@eslint-react/kit 1.40.0-next.1 → 1.40.0-next.3

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.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ } from '@eslint-react/eff';
2
2
  import * as tseslint from '@typescript-eslint/utils/ts-eslint';
3
3
  import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
4
- import { TsConfigJson } from 'get-tsconfig';
4
+ import { CompilerOptions, JsxEmit } from 'typescript';
5
5
 
6
6
  /**
7
7
  * Rule severity.
@@ -36,22 +36,14 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
36
36
  */
37
37
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
38
38
 
39
- type JsxRuntimeOptions = Pick<TsConfigJson.CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
40
- declare const defaultJsxRuntimeOptions: {
41
- readonly jsx: "react-jsx";
42
- readonly jsxFactory: "React.createElement";
43
- readonly jsxFragmentFactory: "React.Fragment";
44
- readonly jsxImportSource: "react";
45
- readonly reactNamespace: "React";
46
- };
39
+ type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
40
+ /**
41
+ * Get JsxRuntimeOptions from RuleContext
42
+ * @param context The RuleContext
43
+ * @returns JsxRuntimeOptions
44
+ */
47
45
  declare function getJsxRuntimeOptionsFromContext(context: RuleContext): {
48
- readonly jsx: "react-jsx";
49
- readonly jsxFactory: "React.createElement";
50
- readonly jsxFragmentFactory: "React.Fragment";
51
- readonly jsxImportSource: "react";
52
- readonly reactNamespace: "React";
53
- } | {
54
- jsx: TsConfigJson.CompilerOptions.JSX;
46
+ jsx: JsxEmit;
55
47
  jsxFactory: string;
56
48
  jsxFragmentFactory: string;
57
49
  jsxImportSource: string;
@@ -59,10 +51,9 @@ declare function getJsxRuntimeOptionsFromContext(context: RuleContext): {
59
51
  };
60
52
 
61
53
  type index_JsxRuntimeOptions = JsxRuntimeOptions;
62
- declare const index_defaultJsxRuntimeOptions: typeof defaultJsxRuntimeOptions;
63
54
  declare const index_getJsxRuntimeOptionsFromContext: typeof getJsxRuntimeOptionsFromContext;
64
55
  declare namespace index {
65
- export { type index_JsxRuntimeOptions as JsxRuntimeOptions, index_defaultJsxRuntimeOptions as defaultJsxRuntimeOptions, index_getJsxRuntimeOptionsFromContext as getJsxRuntimeOptionsFromContext };
56
+ export { type index_JsxRuntimeOptions as JsxRuntimeOptions, index_getJsxRuntimeOptionsFromContext as getJsxRuntimeOptionsFromContext };
66
57
  }
67
58
 
68
59
  /**
@@ -94,6 +85,14 @@ declare const RE_SNAKE_CASE: RegExp;
94
85
  */
95
86
  declare const RE_CONSTANT_CASE: RegExp;
96
87
  declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
88
+ /**
89
+ * Regular expression for matching a JSX pragma comment.
90
+ */
91
+ declare const RE_JSX_ANNOTATION: RegExp;
92
+ /**
93
+ * Regular expression for matching a valid JavaScript identifier.
94
+ */
95
+ declare const RE_JS_IDENTIFIER: RegExp;
97
96
  /**
98
97
  * Regular expression for matching a RegExp string.
99
98
  */
@@ -102,7 +101,7 @@ declare const RE_REGEXP_STR: RegExp;
102
101
  * Convert a string to the `RegExp`.
103
102
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
104
103
  * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
105
- *
104
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
106
105
  * @param string The string to convert.
107
106
  * @returns Returns the `RegExp`.
108
107
  */
@@ -116,4 +115,4 @@ declare function toRegExp(string: string): {
116
115
  */
117
116
  declare function isRegExp(string: string): boolean;
118
117
 
119
- export { index as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
118
+ export { index as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JSX_ANNOTATION, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ } from '@eslint-react/eff';
2
2
  import * as tseslint from '@typescript-eslint/utils/ts-eslint';
3
3
  import { ReportDescriptor } from '@typescript-eslint/utils/ts-eslint';
4
- import { TsConfigJson } from 'get-tsconfig';
4
+ import { CompilerOptions, JsxEmit } from 'typescript';
5
5
 
6
6
  /**
7
7
  * Rule severity.
@@ -36,22 +36,14 @@ type RuleFeature = "CFG" | "DBG" | "FIX" | "MOD" | "TSC" | "EXP";
36
36
  */
37
37
  declare function createReport<MessageID extends string>(context: RuleContext): (descriptor: _ | null | ReportDescriptor<MessageID>) => void;
38
38
 
39
- type JsxRuntimeOptions = Pick<TsConfigJson.CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
40
- declare const defaultJsxRuntimeOptions: {
41
- readonly jsx: "react-jsx";
42
- readonly jsxFactory: "React.createElement";
43
- readonly jsxFragmentFactory: "React.Fragment";
44
- readonly jsxImportSource: "react";
45
- readonly reactNamespace: "React";
46
- };
39
+ type JsxRuntimeOptions = Pick<CompilerOptions, "reactNamespace" | "jsx" | "jsxFactory" | "jsxFragmentFactory" | "jsxImportSource">;
40
+ /**
41
+ * Get JsxRuntimeOptions from RuleContext
42
+ * @param context The RuleContext
43
+ * @returns JsxRuntimeOptions
44
+ */
47
45
  declare function getJsxRuntimeOptionsFromContext(context: RuleContext): {
48
- readonly jsx: "react-jsx";
49
- readonly jsxFactory: "React.createElement";
50
- readonly jsxFragmentFactory: "React.Fragment";
51
- readonly jsxImportSource: "react";
52
- readonly reactNamespace: "React";
53
- } | {
54
- jsx: TsConfigJson.CompilerOptions.JSX;
46
+ jsx: JsxEmit;
55
47
  jsxFactory: string;
56
48
  jsxFragmentFactory: string;
57
49
  jsxImportSource: string;
@@ -59,10 +51,9 @@ declare function getJsxRuntimeOptionsFromContext(context: RuleContext): {
59
51
  };
60
52
 
61
53
  type index_JsxRuntimeOptions = JsxRuntimeOptions;
62
- declare const index_defaultJsxRuntimeOptions: typeof defaultJsxRuntimeOptions;
63
54
  declare const index_getJsxRuntimeOptionsFromContext: typeof getJsxRuntimeOptionsFromContext;
64
55
  declare namespace index {
65
- export { type index_JsxRuntimeOptions as JsxRuntimeOptions, index_defaultJsxRuntimeOptions as defaultJsxRuntimeOptions, index_getJsxRuntimeOptionsFromContext as getJsxRuntimeOptionsFromContext };
56
+ export { type index_JsxRuntimeOptions as JsxRuntimeOptions, index_getJsxRuntimeOptionsFromContext as getJsxRuntimeOptionsFromContext };
66
57
  }
67
58
 
68
59
  /**
@@ -94,6 +85,14 @@ declare const RE_SNAKE_CASE: RegExp;
94
85
  */
95
86
  declare const RE_CONSTANT_CASE: RegExp;
96
87
  declare const RE_JAVASCRIPT_PROTOCOL: RegExp;
88
+ /**
89
+ * Regular expression for matching a JSX pragma comment.
90
+ */
91
+ declare const RE_JSX_ANNOTATION: RegExp;
92
+ /**
93
+ * Regular expression for matching a valid JavaScript identifier.
94
+ */
95
+ declare const RE_JS_IDENTIFIER: RegExp;
97
96
  /**
98
97
  * Regular expression for matching a RegExp string.
99
98
  */
@@ -102,7 +101,7 @@ declare const RE_REGEXP_STR: RegExp;
102
101
  * Convert a string to the `RegExp`.
103
102
  * Normal strings (e.g. `"foo"`) is converted to `/^foo$/` of `RegExp`.
104
103
  * Strings like `"/^foo/i"` are converted to `/^foo/i` of `RegExp`.
105
- *
104
+ * @see https://github.com/sveltejs/eslint-plugin-svelte/blob/main/packages/eslint-plugin-svelte/src/utils/regexp.ts
106
105
  * @param string The string to convert.
107
106
  * @returns Returns the `RegExp`.
108
107
  */
@@ -116,4 +115,4 @@ declare function toRegExp(string: string): {
116
115
  */
117
116
  declare function isRegExp(string: string): boolean;
118
117
 
119
- export { index as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
118
+ export { index as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JSX_ANNOTATION, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, type RuleContext, type RuleDeclaration, type RuleFeature, type RulePreset, type RuleSeverity, createReport, isRegExp, toRegExp };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var getTsconfig = require('get-tsconfig');
3
+ var typescript = require('typescript');
4
4
 
5
5
  var __defProp = Object.defineProperty;
6
6
  var __export = (target, all) => {
@@ -11,27 +11,16 @@ var __export = (target, all) => {
11
11
  // src/JsxRuntime/index.ts
12
12
  var JsxRuntime_exports = {};
13
13
  __export(JsxRuntime_exports, {
14
- defaultJsxRuntimeOptions: () => defaultJsxRuntimeOptions,
15
14
  getJsxRuntimeOptionsFromContext: () => getJsxRuntimeOptionsFromContext
16
15
  });
17
- var defaultJsxRuntimeOptions = {
18
- jsx: "react-jsx",
19
- jsxFactory: "React.createElement",
20
- jsxFragmentFactory: "React.Fragment",
21
- jsxImportSource: "react",
22
- reactNamespace: "React"
23
- };
24
- var tsconfigCache = /* @__PURE__ */ new Map();
25
16
  function getJsxRuntimeOptionsFromContext(context) {
26
- const tsconfigResult = getTsconfig.getTsconfig(context.cwd, "tsconfig.json", tsconfigCache);
27
- const compilerOptions = tsconfigResult?.config.compilerOptions;
28
- if (compilerOptions == null) return defaultJsxRuntimeOptions;
17
+ const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
29
18
  return {
30
- jsx: compilerOptions.jsx ?? defaultJsxRuntimeOptions.jsx,
31
- jsxFactory: compilerOptions.jsxFactory ?? defaultJsxRuntimeOptions.jsxFactory,
32
- jsxFragmentFactory: compilerOptions.jsxFragmentFactory ?? defaultJsxRuntimeOptions.jsxFragmentFactory,
33
- jsxImportSource: compilerOptions.jsxImportSource ?? defaultJsxRuntimeOptions.jsxImportSource,
34
- reactNamespace: compilerOptions.reactNamespace ?? defaultJsxRuntimeOptions.reactNamespace
19
+ jsx: options.jsx ?? typescript.JsxEmit.ReactJSX,
20
+ jsxFactory: options.jsxFactory ?? "React.createElement",
21
+ jsxFragmentFactory: options.jsxFragmentFactory ?? "React.Fragment",
22
+ jsxImportSource: options.jsxImportSource ?? "react",
23
+ reactNamespace: options.reactNamespace ?? "React"
35
24
  };
36
25
  }
37
26
 
@@ -44,6 +33,8 @@ var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
44
33
  var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
45
34
  var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
46
35
  var RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
36
+ var RE_JSX_ANNOTATION = /@jsx\s+(\S+)/;
37
+ var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
47
38
  var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
48
39
  function toRegExp(string) {
49
40
  const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
@@ -65,7 +56,9 @@ exports.JsxRuntime = JsxRuntime_exports;
65
56
  exports.RE_CAMEL_CASE = RE_CAMEL_CASE;
66
57
  exports.RE_CONSTANT_CASE = RE_CONSTANT_CASE;
67
58
  exports.RE_JAVASCRIPT_PROTOCOL = RE_JAVASCRIPT_PROTOCOL;
59
+ exports.RE_JSX_ANNOTATION = RE_JSX_ANNOTATION;
68
60
  exports.RE_JS_EXT = RE_JS_EXT;
61
+ exports.RE_JS_IDENTIFIER = RE_JS_IDENTIFIER;
69
62
  exports.RE_KEBAB_CASE = RE_KEBAB_CASE;
70
63
  exports.RE_PASCAL_CASE = RE_PASCAL_CASE;
71
64
  exports.RE_REGEXP_STR = RE_REGEXP_STR;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { getTsconfig } from 'get-tsconfig';
1
+ import { JsxEmit } from 'typescript';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __export = (target, all) => {
@@ -9,27 +9,16 @@ var __export = (target, all) => {
9
9
  // src/JsxRuntime/index.ts
10
10
  var JsxRuntime_exports = {};
11
11
  __export(JsxRuntime_exports, {
12
- defaultJsxRuntimeOptions: () => defaultJsxRuntimeOptions,
13
12
  getJsxRuntimeOptionsFromContext: () => getJsxRuntimeOptionsFromContext
14
13
  });
15
- var defaultJsxRuntimeOptions = {
16
- jsx: "react-jsx",
17
- jsxFactory: "React.createElement",
18
- jsxFragmentFactory: "React.Fragment",
19
- jsxImportSource: "react",
20
- reactNamespace: "React"
21
- };
22
- var tsconfigCache = /* @__PURE__ */ new Map();
23
14
  function getJsxRuntimeOptionsFromContext(context) {
24
- const tsconfigResult = getTsconfig(context.cwd, "tsconfig.json", tsconfigCache);
25
- const compilerOptions = tsconfigResult?.config.compilerOptions;
26
- if (compilerOptions == null) return defaultJsxRuntimeOptions;
15
+ const options = context.sourceCode.parserServices?.program?.getCompilerOptions() ?? {};
27
16
  return {
28
- jsx: compilerOptions.jsx ?? defaultJsxRuntimeOptions.jsx,
29
- jsxFactory: compilerOptions.jsxFactory ?? defaultJsxRuntimeOptions.jsxFactory,
30
- jsxFragmentFactory: compilerOptions.jsxFragmentFactory ?? defaultJsxRuntimeOptions.jsxFragmentFactory,
31
- jsxImportSource: compilerOptions.jsxImportSource ?? defaultJsxRuntimeOptions.jsxImportSource,
32
- reactNamespace: compilerOptions.reactNamespace ?? defaultJsxRuntimeOptions.reactNamespace
17
+ jsx: options.jsx ?? JsxEmit.ReactJSX,
18
+ jsxFactory: options.jsxFactory ?? "React.createElement",
19
+ jsxFragmentFactory: options.jsxFragmentFactory ?? "React.Fragment",
20
+ jsxImportSource: options.jsxImportSource ?? "react",
21
+ reactNamespace: options.reactNamespace ?? "React"
33
22
  };
34
23
  }
35
24
 
@@ -42,6 +31,8 @@ var RE_KEBAB_CASE = /^[a-z][\d\-a-z]*$/u;
42
31
  var RE_SNAKE_CASE = /^[a-z][\d_a-z]*$/u;
43
32
  var RE_CONSTANT_CASE = /^[A-Z][\d_A-Z]*$/u;
44
33
  var RE_JAVASCRIPT_PROTOCOL = /^[\u0000-\u001F ]*j[\t\n\r]*a[\t\n\r]*v[\t\n\r]*a[\t\n\r]*s[\t\n\r]*c[\t\n\r]*r[\t\n\r]*i[\t\n\r]*p[\t\n\r]*t[\t\n\r]*:/iu;
34
+ var RE_JSX_ANNOTATION = /@jsx\s+(\S+)/;
35
+ var RE_JS_IDENTIFIER = /^[_$a-z][\w$]*$/i;
45
36
  var RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
46
37
  function toRegExp(string) {
47
38
  const [, pattern, flags = "u"] = RE_REGEXP_STR.exec(string) ?? [];
@@ -59,4 +50,4 @@ function createReport(context) {
59
50
  };
60
51
  }
61
52
 
62
- export { JsxRuntime_exports as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JS_EXT, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, createReport, isRegExp, toRegExp };
53
+ export { JsxRuntime_exports as JsxRuntime, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_JSX_ANNOTATION, RE_JS_EXT, RE_JS_IDENTIFIER, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_REGEXP_STR, RE_SNAKE_CASE, RE_TS_EXT, createReport, isRegExp, toRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/kit",
3
- "version": "1.40.0-next.1",
3
+ "version": "1.40.0-next.3",
4
4
  "description": "ESLint React's Plugin Kit for building plugins and rules.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -36,9 +36,8 @@
36
36
  ],
37
37
  "dependencies": {
38
38
  "@typescript-eslint/utils": "^8.29.0",
39
- "get-tsconfig": "^4.10.0",
40
39
  "ts-pattern": "^5.7.0",
41
- "@eslint-react/eff": "1.40.0-next.1"
40
+ "@eslint-react/eff": "1.40.0-next.3"
42
41
  },
43
42
  "devDependencies": {
44
43
  "@tsconfig/node22": "^22.0.1",