@eslint-react/shared 1.23.3-next.7 → 1.24.0-next.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.
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ declare const NPM_SCOPE = "@eslint-react";
7
7
  /**
8
8
  * The GitHub repository for this project.
9
9
  */
10
- declare const GITHUB_URL = "https://github.com/rEl1cx/eslint-react";
10
+ declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
11
11
  /**
12
12
  * The URL to the project's website.
13
13
  */
@@ -1491,7 +1491,7 @@ declare const CustomComponentSchema: ObjectSchema<{
1491
1491
  }, undefined>;
1492
1492
  declare const CustomComponentNormalizedSchema: ObjectSchema<{
1493
1493
  readonly name: StringSchema<undefined>;
1494
- readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
1494
+ readonly as: StringSchema<undefined>;
1495
1495
  readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
1496
1496
  /**
1497
1497
  * The name of the attribute in the user-defined component.
@@ -1917,7 +1917,6 @@ type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
1917
1917
  */
1918
1918
  interface ESLintReactSettingsNormalized extends ESLintReactSettings {
1919
1919
  additionalComponents: CustomComponentNormalized[];
1920
- components: Map<string, string>;
1921
1920
  version: string;
1922
1921
  }
1923
1922
 
@@ -2052,7 +2051,7 @@ Matches any primitive, `void`, `Date`, or `RegExp` value.
2052
2051
  type BuiltIns = Primitive | void | Date | RegExp;
2053
2052
 
2054
2053
  /**
2055
- @see PartialDeep
2054
+ @see {@link PartialDeep}
2056
2055
  */
2057
2056
  type PartialDeepOptions = {
2058
2057
  /**
@@ -2061,6 +2060,32 @@ type PartialDeepOptions = {
2061
2060
  @default false
2062
2061
  */
2063
2062
  readonly recurseIntoArrays?: boolean;
2063
+
2064
+ /**
2065
+ Allows `undefined` values in non-tuple arrays.
2066
+
2067
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
2068
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
2069
+
2070
+ @default true
2071
+
2072
+ @example
2073
+ You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
2074
+
2075
+ ```
2076
+ import type {PartialDeep} from 'type-fest';
2077
+
2078
+ type Settings = {
2079
+ languages: string[];
2080
+ };
2081
+
2082
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
2083
+
2084
+ partialSettings.languages = [undefined]; // Error
2085
+ partialSettings.languages = []; // Ok
2086
+ ```
2087
+ */
2088
+ readonly allowUndefinedInNonTupleArrays?: boolean;
2064
2089
  };
2065
2090
 
2066
2091
  /**
@@ -2076,12 +2101,12 @@ import type {PartialDeep} from 'type-fest';
2076
2101
 
2077
2102
  const settings: Settings = {
2078
2103
  textEditor: {
2079
- fontSize: 14;
2080
- fontColor: '#000000';
2081
- fontWeight: 400;
2082
- }
2083
- autocomplete: false;
2084
- autosave: true;
2104
+ fontSize: 14,
2105
+ fontColor: '#000000',
2106
+ fontWeight: 400
2107
+ },
2108
+ autocomplete: false,
2109
+ autosave: true
2085
2110
  };
2086
2111
 
2087
2112
  const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
@@ -2096,7 +2121,7 @@ By default, this does not affect elements in array and tuple types. You can chan
2096
2121
  ```
2097
2122
  import type {PartialDeep} from 'type-fest';
2098
2123
 
2099
- interface Settings {
2124
+ type Settings = {
2100
2125
  languages: string[];
2101
2126
  }
2102
2127
 
@@ -2105,6 +2130,8 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2105
2130
  };
2106
2131
  ```
2107
2132
 
2133
+ @see {@link PartialDeepOptions}
2134
+
2108
2135
  @category Object
2109
2136
  @category Array
2110
2137
  @category Set
@@ -2125,8 +2152,8 @@ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIn
2125
2152
  ? Options['recurseIntoArrays'] extends true
2126
2153
  ? ItemType[] extends T // Test for arrays (non-tuples) specifically
2127
2154
  ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
2128
- ? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
2129
- : Array<PartialDeep<ItemType | undefined, Options>>
2155
+ ? ReadonlyArray<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2156
+ : Array<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2130
2157
  : PartialObjectDeep<T, Options> // Tuples behave properly
2131
2158
  : T // If they don't opt into array testing, just use the original type
2132
2159
  : PartialObjectDeep<T, Options>
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ declare const NPM_SCOPE = "@eslint-react";
7
7
  /**
8
8
  * The GitHub repository for this project.
9
9
  */
10
- declare const GITHUB_URL = "https://github.com/rEl1cx/eslint-react";
10
+ declare const GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
11
11
  /**
12
12
  * The URL to the project's website.
13
13
  */
@@ -1491,7 +1491,7 @@ declare const CustomComponentSchema: ObjectSchema<{
1491
1491
  }, undefined>;
1492
1492
  declare const CustomComponentNormalizedSchema: ObjectSchema<{
1493
1493
  readonly name: StringSchema<undefined>;
1494
- readonly as: OptionalSchema<StringSchema<undefined>, undefined>;
1494
+ readonly as: StringSchema<undefined>;
1495
1495
  readonly attributes: OptionalSchema<ArraySchema<ObjectSchema<{
1496
1496
  /**
1497
1497
  * The name of the attribute in the user-defined component.
@@ -1917,7 +1917,6 @@ type ESLintSettings = InferOutput<typeof ESLintSettingsSchema>;
1917
1917
  */
1918
1918
  interface ESLintReactSettingsNormalized extends ESLintReactSettings {
1919
1919
  additionalComponents: CustomComponentNormalized[];
1920
- components: Map<string, string>;
1921
1920
  version: string;
1922
1921
  }
1923
1922
 
@@ -2052,7 +2051,7 @@ Matches any primitive, `void`, `Date`, or `RegExp` value.
2052
2051
  type BuiltIns = Primitive | void | Date | RegExp;
2053
2052
 
2054
2053
  /**
2055
- @see PartialDeep
2054
+ @see {@link PartialDeep}
2056
2055
  */
2057
2056
  type PartialDeepOptions = {
2058
2057
  /**
@@ -2061,6 +2060,32 @@ type PartialDeepOptions = {
2061
2060
  @default false
2062
2061
  */
2063
2062
  readonly recurseIntoArrays?: boolean;
2063
+
2064
+ /**
2065
+ Allows `undefined` values in non-tuple arrays.
2066
+
2067
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
2068
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
2069
+
2070
+ @default true
2071
+
2072
+ @example
2073
+ You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
2074
+
2075
+ ```
2076
+ import type {PartialDeep} from 'type-fest';
2077
+
2078
+ type Settings = {
2079
+ languages: string[];
2080
+ };
2081
+
2082
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
2083
+
2084
+ partialSettings.languages = [undefined]; // Error
2085
+ partialSettings.languages = []; // Ok
2086
+ ```
2087
+ */
2088
+ readonly allowUndefinedInNonTupleArrays?: boolean;
2064
2089
  };
2065
2090
 
2066
2091
  /**
@@ -2076,12 +2101,12 @@ import type {PartialDeep} from 'type-fest';
2076
2101
 
2077
2102
  const settings: Settings = {
2078
2103
  textEditor: {
2079
- fontSize: 14;
2080
- fontColor: '#000000';
2081
- fontWeight: 400;
2082
- }
2083
- autocomplete: false;
2084
- autosave: true;
2104
+ fontSize: 14,
2105
+ fontColor: '#000000',
2106
+ fontWeight: 400
2107
+ },
2108
+ autocomplete: false,
2109
+ autosave: true
2085
2110
  };
2086
2111
 
2087
2112
  const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
@@ -2096,7 +2121,7 @@ By default, this does not affect elements in array and tuple types. You can chan
2096
2121
  ```
2097
2122
  import type {PartialDeep} from 'type-fest';
2098
2123
 
2099
- interface Settings {
2124
+ type Settings = {
2100
2125
  languages: string[];
2101
2126
  }
2102
2127
 
@@ -2105,6 +2130,8 @@ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
2105
2130
  };
2106
2131
  ```
2107
2132
 
2133
+ @see {@link PartialDeepOptions}
2134
+
2108
2135
  @category Object
2109
2136
  @category Array
2110
2137
  @category Set
@@ -2125,8 +2152,8 @@ type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends BuiltIn
2125
2152
  ? Options['recurseIntoArrays'] extends true
2126
2153
  ? ItemType[] extends T // Test for arrays (non-tuples) specifically
2127
2154
  ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
2128
- ? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
2129
- : Array<PartialDeep<ItemType | undefined, Options>>
2155
+ ? ReadonlyArray<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2156
+ : Array<PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
2130
2157
  : PartialObjectDeep<T, Options> // Tuples behave properly
2131
2158
  : T // If they don't opt into array testing, just use the original type
2132
2159
  : PartialObjectDeep<T, Options>
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var pm__default = /*#__PURE__*/_interopDefault(pm);
14
14
 
15
15
  // src/constants.ts
16
16
  var NPM_SCOPE = "@eslint-react";
17
- var GITHUB_URL = "https://github.com/rEl1cx/eslint-react";
17
+ var GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
18
18
  var WEBSITE_URL = "https://eslint-react.xyz";
19
19
  var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
20
20
  var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
@@ -224,7 +224,7 @@ var createRuleForPlugin = (pluginName) => utils.ESLintUtils.RuleCreator(getDocsU
224
224
  var _require = module__default.default.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
225
225
  function getReactVersion(fallback = "19.0.0") {
226
226
  try {
227
- return tsPattern.match(_require("react")).with({ version: tsPattern.P.select(tsPattern.P.string) }, eff.F.identity).otherwise(eff.F.constant(fallback));
227
+ return tsPattern.match(_require("react")).with({ version: tsPattern.P.select(tsPattern.P.string) }, eff.identity).otherwise(() => fallback);
228
228
  } catch {
229
229
  return fallback;
230
230
  }
@@ -614,7 +614,7 @@ var CustomComponentSchema = object({
614
614
  });
615
615
  var CustomComponentNormalizedSchema = object({
616
616
  name: string(),
617
- as: optional(string()),
617
+ as: string(),
618
618
  attributes: optional(array(CustomAttributeSchema), []),
619
619
  re: instance(RegExp),
620
620
  selector: optional(string())
@@ -1419,29 +1419,20 @@ var normalizeSettings = createMemoizedFunction((settings) => {
1419
1419
  ...settings,
1420
1420
  additionalComponents: additionalComponents.map((component) => ({
1421
1421
  ...component,
1422
+ as: component.as ?? component.name,
1422
1423
  attributes: component.attributes?.map((attr) => ({
1423
1424
  ...attr,
1424
1425
  as: attr.as ?? attr.name
1425
1426
  })) ?? [],
1426
1427
  re: pm__default.default.makeRe(component.name, { fastpaths: true })
1427
1428
  })),
1428
- components: additionalComponents.reduce((acc, component) => {
1429
- const { name, as, attributes = [], selector } = component;
1430
- if (!name || !as || selector || attributes.length > 0) {
1431
- return acc;
1432
- }
1433
- if (!/^[\w-]+$/u.test(name)) {
1434
- return acc;
1435
- }
1436
- return acc.set(name, as);
1437
- }, /* @__PURE__ */ new Map()),
1438
- version: tsPattern.match(settings.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(eff.F.identity)
1429
+ version: tsPattern.match(settings.version).with(tsPattern.P.union(tsPattern.P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(eff.identity)
1439
1430
  };
1440
1431
  }, { isEqual: shallowEqual });
1441
1432
  function getSettingsFromContext(context) {
1442
1433
  return normalizeSettings(decodeSettings(context.settings));
1443
1434
  }
1444
- var defineSettings = eff.F.identity;
1435
+ var defineSettings = eff.identity;
1445
1436
 
1446
1437
  exports.CustomAttributeSchema = CustomAttributeSchema;
1447
1438
  exports.CustomComponentNormalizedSchema = CustomComponentNormalizedSchema;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ESLintUtils } from '@typescript-eslint/utils';
2
2
  import module from 'node:module';
3
- import { F } from '@eslint-react/eff';
3
+ import { identity } from '@eslint-react/eff';
4
4
  import { match, P } from 'ts-pattern';
5
5
  import pm from 'picomatch';
6
6
 
7
7
  // src/constants.ts
8
8
  var NPM_SCOPE = "@eslint-react";
9
- var GITHUB_URL = "https://github.com/rEl1cx/eslint-react";
9
+ var GITHUB_URL = "https://github.com/Rel1cx/eslint-react";
10
10
  var WEBSITE_URL = "https://eslint-react.xyz";
11
11
  var RE_PASCAL_CASE = /^[A-Z][\dA-Za-z]*$/u;
12
12
  var RE_CAMEL_CASE = /^[a-z][\dA-Za-z]*$/u;
@@ -216,7 +216,7 @@ var createRuleForPlugin = (pluginName) => ESLintUtils.RuleCreator(getDocsUrl(plu
216
216
  var _require = module.createRequire(import.meta.url);
217
217
  function getReactVersion(fallback = "19.0.0") {
218
218
  try {
219
- return match(_require("react")).with({ version: P.select(P.string) }, F.identity).otherwise(F.constant(fallback));
219
+ return match(_require("react")).with({ version: P.select(P.string) }, identity).otherwise(() => fallback);
220
220
  } catch {
221
221
  return fallback;
222
222
  }
@@ -606,7 +606,7 @@ var CustomComponentSchema = object({
606
606
  });
607
607
  var CustomComponentNormalizedSchema = object({
608
608
  name: string(),
609
- as: optional(string()),
609
+ as: string(),
610
610
  attributes: optional(array(CustomAttributeSchema), []),
611
611
  re: instance(RegExp),
612
612
  selector: optional(string())
@@ -1411,28 +1411,19 @@ var normalizeSettings = createMemoizedFunction((settings) => {
1411
1411
  ...settings,
1412
1412
  additionalComponents: additionalComponents.map((component) => ({
1413
1413
  ...component,
1414
+ as: component.as ?? component.name,
1414
1415
  attributes: component.attributes?.map((attr) => ({
1415
1416
  ...attr,
1416
1417
  as: attr.as ?? attr.name
1417
1418
  })) ?? [],
1418
1419
  re: pm.makeRe(component.name, { fastpaths: true })
1419
1420
  })),
1420
- components: additionalComponents.reduce((acc, component) => {
1421
- const { name, as, attributes = [], selector } = component;
1422
- if (!name || !as || selector || attributes.length > 0) {
1423
- return acc;
1424
- }
1425
- if (!/^[\w-]+$/u.test(name)) {
1426
- return acc;
1427
- }
1428
- return acc.set(name, as);
1429
- }, /* @__PURE__ */ new Map()),
1430
- version: match(settings.version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(F.identity)
1421
+ version: match(settings.version).with(P.union(P.nullish, "", "detect"), () => getReactVersion("19.0.0")).otherwise(identity)
1431
1422
  };
1432
1423
  }, { isEqual: shallowEqual });
1433
1424
  function getSettingsFromContext(context) {
1434
1425
  return normalizeSettings(decodeSettings(context.settings));
1435
1426
  }
1436
- var defineSettings = F.identity;
1427
+ var defineSettings = identity;
1437
1428
 
1438
1429
  export { CustomAttributeSchema, CustomComponentNormalizedSchema, CustomComponentSchema, CustomHookSchema, DEFAULT_ESLINT_REACT_SETTINGS, DOM_HTML_COMPONENT_TYPES, DOM_SVG_COMPONENT_TYPES, ESLintReactSettingsSchema, ESLintSettingsSchema, GITHUB_URL, NPM_SCOPE, REACT_BUILD_IN_HOOKS, RE_CAMEL_CASE, RE_CONSTANT_CASE, RE_JAVASCRIPT_PROTOCOL, RE_KEBAB_CASE, RE_PASCAL_CASE, RE_SNAKE_CASE, WEBSITE_URL, createRuleForPlugin, decodeSettings, defineSettings, getReactVersion, getSettingsFromContext, normalizeSettings, unsafeDecodeSettings };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@eslint-react/shared",
3
- "version": "1.23.3-next.7",
3
+ "version": "1.24.0-next.0",
4
4
  "description": "ESLint React's Shared constants and functions.",
5
- "homepage": "https://github.com/rEl1cx/eslint-react",
5
+ "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
7
- "url": "https://github.com/rEl1cx/eslint-react/issues"
7
+ "url": "https://github.com/Rel1cx/eslint-react/issues"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/rEl1cx/eslint-react.git",
11
+ "url": "git+https://github.com/Rel1cx/eslint-react.git",
12
12
  "directory": "packages/shared"
13
13
  },
14
14
  "license": "MIT",
@@ -36,14 +36,14 @@
36
36
  "@typescript-eslint/utils": "^8.19.1",
37
37
  "picomatch": "^4.0.2",
38
38
  "ts-pattern": "^5.6.0",
39
- "@eslint-react/eff": "1.23.3-next.7"
39
+ "@eslint-react/eff": "1.24.0-next.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/picomatch": "^3.0.1",
43
43
  "fast-equals": "^5.2.2",
44
44
  "micro-memoize": "^4.1.3",
45
45
  "tsup": "^8.3.5",
46
- "type-fest": "^4.31.0",
46
+ "type-fest": "^4.32.0",
47
47
  "valibot": "^1.0.0-beta.11",
48
48
  "@workspace/configs": "0.0.0"
49
49
  },