@ncontiero/eslint-config 7.3.0-beta.0 → 7.3.0-beta.2
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 +72 -77
- package/dist/index.mjs +59 -4
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -4208,11 +4208,6 @@ interface RuleOptions {
|
|
|
4208
4208
|
*/
|
|
4209
4209
|
'radix'?: Linter.RuleEntry<Radix>;
|
|
4210
4210
|
'react-refresh/only-export-components'?: Linter.RuleEntry<ReactRefreshOnlyExportComponents>;
|
|
4211
|
-
/**
|
|
4212
|
-
* Disallows higher order functions that define components or hooks inside them.
|
|
4213
|
-
* @see https://eslint-react.xyz/docs/rules/component-hook-factories
|
|
4214
|
-
*/
|
|
4215
|
-
'react/component-hook-factories'?: Linter.RuleEntry<[]>;
|
|
4216
4211
|
/**
|
|
4217
4212
|
* Disallows DOM elements from using 'dangerouslySetInnerHTML'.
|
|
4218
4213
|
* @see https://eslint-react.xyz/docs/rules/dom-no-dangerously-set-innerhtml
|
|
@@ -4293,11 +4288,6 @@ interface RuleOptions {
|
|
|
4293
4288
|
* @see https://eslint-react.xyz/docs/rules/dom-no-void-elements-with-children
|
|
4294
4289
|
*/
|
|
4295
4290
|
'react/dom-no-void-elements-with-children'?: Linter.RuleEntry<[]>;
|
|
4296
|
-
/**
|
|
4297
|
-
* Enforces importing React DOM via a namespace import.
|
|
4298
|
-
* @see https://eslint-react.xyz/docs/rules/dom-prefer-namespace-import
|
|
4299
|
-
*/
|
|
4300
|
-
'react/dom-prefer-namespace-import'?: Linter.RuleEntry<[]>;
|
|
4301
4291
|
/**
|
|
4302
4292
|
* Validates usage of Error Boundaries instead of try/catch for errors in child components.
|
|
4303
4293
|
* @see https://eslint-react.xyz/docs/rules/error-boundaries
|
|
@@ -4308,6 +4298,11 @@ interface RuleOptions {
|
|
|
4308
4298
|
* @see https://github.com/facebook/react/issues/14920
|
|
4309
4299
|
*/
|
|
4310
4300
|
'react/exhaustive-deps'?: Linter.RuleEntry<ReactExhaustiveDeps>;
|
|
4301
|
+
/**
|
|
4302
|
+
* Validates against assignment/mutation of globals during render, part of ensuring that side effects must run outside of render.
|
|
4303
|
+
* @see https://eslint-react.xyz/docs/rules/globals
|
|
4304
|
+
*/
|
|
4305
|
+
'react/globals'?: Linter.RuleEntry<[]>;
|
|
4311
4306
|
/**
|
|
4312
4307
|
* Validates against mutating props, state, and other values that are immutable.
|
|
4313
4308
|
* @see https://eslint-react.xyz/docs/rules/immutability
|
|
@@ -4503,11 +4498,6 @@ interface RuleOptions {
|
|
|
4503
4498
|
* @see https://eslint-react.xyz/docs/rules/no-nested-lazy-component-declarations
|
|
4504
4499
|
*/
|
|
4505
4500
|
'react/no-nested-lazy-component-declarations'?: Linter.RuleEntry<[]>;
|
|
4506
|
-
/**
|
|
4507
|
-
* Disallows 'shouldComponentUpdate' when extending 'React.PureComponent'.
|
|
4508
|
-
* @see https://eslint-react.xyz/docs/rules/no-redundant-should-component-update
|
|
4509
|
-
*/
|
|
4510
|
-
'react/no-redundant-should-component-update'?: Linter.RuleEntry<[]>;
|
|
4511
4501
|
/**
|
|
4512
4502
|
* Disallows calling 'this.setState' in 'componentDidMount' outside functions such as callbacks.
|
|
4513
4503
|
* @see https://eslint-react.xyz/docs/rules/no-set-state-in-component-did-mount
|
|
@@ -4523,16 +4513,6 @@ interface RuleOptions {
|
|
|
4523
4513
|
* @see https://eslint-react.xyz/docs/rules/no-set-state-in-component-will-update
|
|
4524
4514
|
*/
|
|
4525
4515
|
'react/no-set-state-in-component-will-update'?: Linter.RuleEntry<[]>;
|
|
4526
|
-
/**
|
|
4527
|
-
* Disallows unnecessary usage of 'useCallback'.
|
|
4528
|
-
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-callback
|
|
4529
|
-
*/
|
|
4530
|
-
'react/no-unnecessary-use-callback'?: Linter.RuleEntry<[]>;
|
|
4531
|
-
/**
|
|
4532
|
-
* Disallows unnecessary usage of 'useMemo'.
|
|
4533
|
-
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-memo
|
|
4534
|
-
*/
|
|
4535
|
-
'react/no-unnecessary-use-memo'?: Linter.RuleEntry<[]>;
|
|
4536
4516
|
/**
|
|
4537
4517
|
* Enforces that a function with the 'use' prefix uses at least one Hook inside it.
|
|
4538
4518
|
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-prefix
|
|
@@ -4573,26 +4553,11 @@ interface RuleOptions {
|
|
|
4573
4553
|
* @see https://eslint-react.xyz/docs/rules/no-unused-props
|
|
4574
4554
|
*/
|
|
4575
4555
|
'react/no-unused-props'?: Linter.RuleEntry<[]>;
|
|
4576
|
-
/**
|
|
4577
|
-
* Warns about unused class component state.
|
|
4578
|
-
* @see https://eslint-react.xyz/docs/rules/no-unused-state
|
|
4579
|
-
*/
|
|
4580
|
-
'react/no-unused-state'?: Linter.RuleEntry<[]>;
|
|
4581
4556
|
/**
|
|
4582
4557
|
* Replaces usage of 'useContext' with 'use'.
|
|
4583
4558
|
* @see https://eslint-react.xyz/docs/rules/no-use-context
|
|
4584
4559
|
*/
|
|
4585
4560
|
'react/no-use-context'?: Linter.RuleEntry<[]>;
|
|
4586
|
-
/**
|
|
4587
|
-
* Enforces destructuring assignment for component props and context.
|
|
4588
|
-
* @see https://eslint-react.xyz/docs/rules/prefer-destructuring-assignment
|
|
4589
|
-
*/
|
|
4590
|
-
'react/prefer-destructuring-assignment'?: Linter.RuleEntry<[]>;
|
|
4591
|
-
/**
|
|
4592
|
-
* Enforces importing React via a namespace import.
|
|
4593
|
-
* @see https://eslint-react.xyz/docs/rules/prefer-namespace-import
|
|
4594
|
-
*/
|
|
4595
|
-
'react/prefer-namespace-import'?: Linter.RuleEntry<[]>;
|
|
4596
4561
|
/**
|
|
4597
4562
|
* Validates that components and hooks are pure by checking that they do not call known-impure functions during render.
|
|
4598
4563
|
* @see https://eslint-react.xyz/docs/rules/purity
|
|
@@ -4623,6 +4588,11 @@ interface RuleOptions {
|
|
|
4623
4588
|
* @see https://eslint-react.xyz/docs/rules/set-state-in-render
|
|
4624
4589
|
*/
|
|
4625
4590
|
'react/set-state-in-render'?: Linter.RuleEntry<[]>;
|
|
4591
|
+
/**
|
|
4592
|
+
* Validates that components are static, not recreated every render.
|
|
4593
|
+
* @see https://eslint-react.xyz/docs/rules/static-components
|
|
4594
|
+
*/
|
|
4595
|
+
'react/static-components'?: Linter.RuleEntry<[]>;
|
|
4626
4596
|
/**
|
|
4627
4597
|
* Validates against syntax that React Compiler does not support.
|
|
4628
4598
|
* @see https://eslint-react.xyz/docs/rules/unsupported-syntax
|
|
@@ -4643,6 +4613,11 @@ interface RuleOptions {
|
|
|
4643
4613
|
* @see https://eslint-react.xyz/docs/rules/web-api-no-leaked-event-listener
|
|
4644
4614
|
*/
|
|
4645
4615
|
'react/web-api-no-leaked-event-listener'?: Linter.RuleEntry<[]>;
|
|
4616
|
+
/**
|
|
4617
|
+
* Enforces that every 'fetch' in a component or custom hook has a corresponding 'AbortController' abort in the cleanup function.
|
|
4618
|
+
* @see https://eslint-react.xyz/docs/rules/web-api-no-leaked-fetch
|
|
4619
|
+
*/
|
|
4620
|
+
'react/web-api-no-leaked-fetch'?: Linter.RuleEntry<[]>;
|
|
4646
4621
|
/**
|
|
4647
4622
|
* Enforces that every 'setInterval' in a component or custom hook has a corresponding 'clearInterval'.
|
|
4648
4623
|
* @see https://eslint-react.xyz/docs/rules/web-api-no-leaked-interval
|
|
@@ -4658,11 +4633,6 @@ interface RuleOptions {
|
|
|
4658
4633
|
* @see https://eslint-react.xyz/docs/rules/web-api-no-leaked-timeout
|
|
4659
4634
|
*/
|
|
4660
4635
|
'react/web-api-no-leaked-timeout'?: Linter.RuleEntry<[]>;
|
|
4661
|
-
/**
|
|
4662
|
-
* Disallows higher order functions that define components or hooks inside them.
|
|
4663
|
-
* @see https://eslint-react.xyz/docs/rules/component-hook-factories
|
|
4664
|
-
*/
|
|
4665
|
-
'react/x-component-hook-factories'?: Linter.RuleEntry<[]>;
|
|
4666
4636
|
/**
|
|
4667
4637
|
* Validates usage of Error Boundaries instead of try/catch for errors in child components.
|
|
4668
4638
|
* @see https://eslint-react.xyz/docs/rules/error-boundaries
|
|
@@ -4673,6 +4643,11 @@ interface RuleOptions {
|
|
|
4673
4643
|
* @see https://github.com/facebook/react/issues/14920
|
|
4674
4644
|
*/
|
|
4675
4645
|
'react/x-exhaustive-deps'?: Linter.RuleEntry<ReactXExhaustiveDeps>;
|
|
4646
|
+
/**
|
|
4647
|
+
* Validates against assignment/mutation of globals during render, part of ensuring that side effects must run outside of render.
|
|
4648
|
+
* @see https://eslint-react.xyz/docs/rules/globals
|
|
4649
|
+
*/
|
|
4650
|
+
'react/x-globals'?: Linter.RuleEntry<[]>;
|
|
4676
4651
|
/**
|
|
4677
4652
|
* Validates against mutating props, state, and other values that are immutable.
|
|
4678
4653
|
* @see https://eslint-react.xyz/docs/rules/immutability
|
|
@@ -4813,11 +4788,6 @@ interface RuleOptions {
|
|
|
4813
4788
|
* @see https://eslint-react.xyz/docs/rules/no-nested-lazy-component-declarations
|
|
4814
4789
|
*/
|
|
4815
4790
|
'react/x-no-nested-lazy-component-declarations'?: Linter.RuleEntry<[]>;
|
|
4816
|
-
/**
|
|
4817
|
-
* Disallows 'shouldComponentUpdate' when extending 'React.PureComponent'.
|
|
4818
|
-
* @see https://eslint-react.xyz/docs/rules/no-redundant-should-component-update
|
|
4819
|
-
*/
|
|
4820
|
-
'react/x-no-redundant-should-component-update'?: Linter.RuleEntry<[]>;
|
|
4821
4791
|
/**
|
|
4822
4792
|
* Disallows calling 'this.setState' in 'componentDidMount' outside functions such as callbacks.
|
|
4823
4793
|
* @see https://eslint-react.xyz/docs/rules/no-set-state-in-component-did-mount
|
|
@@ -4833,16 +4803,6 @@ interface RuleOptions {
|
|
|
4833
4803
|
* @see https://eslint-react.xyz/docs/rules/no-set-state-in-component-will-update
|
|
4834
4804
|
*/
|
|
4835
4805
|
'react/x-no-set-state-in-component-will-update'?: Linter.RuleEntry<[]>;
|
|
4836
|
-
/**
|
|
4837
|
-
* Disallows unnecessary usage of 'useCallback'.
|
|
4838
|
-
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-callback
|
|
4839
|
-
*/
|
|
4840
|
-
'react/x-no-unnecessary-use-callback'?: Linter.RuleEntry<[]>;
|
|
4841
|
-
/**
|
|
4842
|
-
* Disallows unnecessary usage of 'useMemo'.
|
|
4843
|
-
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-memo
|
|
4844
|
-
*/
|
|
4845
|
-
'react/x-no-unnecessary-use-memo'?: Linter.RuleEntry<[]>;
|
|
4846
4806
|
/**
|
|
4847
4807
|
* Enforces that a function with the 'use' prefix uses at least one Hook inside it.
|
|
4848
4808
|
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-prefix
|
|
@@ -4883,26 +4843,11 @@ interface RuleOptions {
|
|
|
4883
4843
|
* @see https://eslint-react.xyz/docs/rules/no-unused-props
|
|
4884
4844
|
*/
|
|
4885
4845
|
'react/x-no-unused-props'?: Linter.RuleEntry<[]>;
|
|
4886
|
-
/**
|
|
4887
|
-
* Warns about unused class component state.
|
|
4888
|
-
* @see https://eslint-react.xyz/docs/rules/no-unused-state
|
|
4889
|
-
*/
|
|
4890
|
-
'react/x-no-unused-state'?: Linter.RuleEntry<[]>;
|
|
4891
4846
|
/**
|
|
4892
4847
|
* Replaces usage of 'useContext' with 'use'.
|
|
4893
4848
|
* @see https://eslint-react.xyz/docs/rules/no-use-context
|
|
4894
4849
|
*/
|
|
4895
4850
|
'react/x-no-use-context'?: Linter.RuleEntry<[]>;
|
|
4896
|
-
/**
|
|
4897
|
-
* Enforces destructuring assignment for component props and context.
|
|
4898
|
-
* @see https://eslint-react.xyz/docs/rules/prefer-destructuring-assignment
|
|
4899
|
-
*/
|
|
4900
|
-
'react/x-prefer-destructuring-assignment'?: Linter.RuleEntry<[]>;
|
|
4901
|
-
/**
|
|
4902
|
-
* Enforces importing React via a namespace import.
|
|
4903
|
-
* @see https://eslint-react.xyz/docs/rules/prefer-namespace-import
|
|
4904
|
-
*/
|
|
4905
|
-
'react/x-prefer-namespace-import'?: Linter.RuleEntry<[]>;
|
|
4906
4851
|
/**
|
|
4907
4852
|
* Validates that components and hooks are pure by checking that they do not call known-impure functions during render.
|
|
4908
4853
|
* @see https://eslint-react.xyz/docs/rules/purity
|
|
@@ -4928,6 +4873,11 @@ interface RuleOptions {
|
|
|
4928
4873
|
* @see https://eslint-react.xyz/docs/rules/set-state-in-render
|
|
4929
4874
|
*/
|
|
4930
4875
|
'react/x-set-state-in-render'?: Linter.RuleEntry<[]>;
|
|
4876
|
+
/**
|
|
4877
|
+
* Validates that components are static, not recreated every render.
|
|
4878
|
+
* @see https://eslint-react.xyz/docs/rules/static-components
|
|
4879
|
+
*/
|
|
4880
|
+
'react/x-static-components'?: Linter.RuleEntry<[]>;
|
|
4931
4881
|
/**
|
|
4932
4882
|
* Validates against syntax that React Compiler does not support.
|
|
4933
4883
|
* @see https://eslint-react.xyz/docs/rules/unsupported-syntax
|
|
@@ -16695,6 +16645,9 @@ declare const hasTailwind: boolean;
|
|
|
16695
16645
|
declare const hasTanStackReactQuery: boolean;
|
|
16696
16646
|
//#endregion
|
|
16697
16647
|
//#region src/factory.d.ts
|
|
16648
|
+
declare const defaultPluginRenaming: {
|
|
16649
|
+
"@eslint-react": string;
|
|
16650
|
+
};
|
|
16698
16651
|
type ResolvedOptions<T> = T extends boolean ? never : NonNullable<T>;
|
|
16699
16652
|
declare function resolveSubOptions<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): ResolvedOptions<OptionsConfig[K]>;
|
|
16700
16653
|
declare function getOverrides<K extends keyof OptionsConfig>(options: OptionsConfig, key: K): Partial<Linter.RulesRecord & Rules>;
|
|
@@ -16769,7 +16722,49 @@ declare function interopDefault<T>(m: Awaitable<T>): Promise<T extends {
|
|
|
16769
16722
|
default: infer U;
|
|
16770
16723
|
} ? U : T>;
|
|
16771
16724
|
declare function ensurePackages(packages: (string | undefined)[]): void;
|
|
16772
|
-
|
|
16725
|
+
interface ComposerOptions {
|
|
16726
|
+
items: Awaitable<FlatConfigItem[]>[];
|
|
16727
|
+
pluginsNameMap?: Record<string, string>;
|
|
16728
|
+
}
|
|
16729
|
+
declare function composer({
|
|
16730
|
+
items,
|
|
16731
|
+
pluginsNameMap
|
|
16732
|
+
}: ComposerOptions): Promise<FlatConfigItem[]>;
|
|
16733
|
+
/**
|
|
16734
|
+
* Rename plugin prefixes in a rule object.
|
|
16735
|
+
* Accepts a map of prefixes to rename.
|
|
16736
|
+
*
|
|
16737
|
+
* @example
|
|
16738
|
+
* ```ts
|
|
16739
|
+
* import { renameRules } from "@ncontiero/eslint-config";
|
|
16740
|
+
*
|
|
16741
|
+
* export default [
|
|
16742
|
+
* {
|
|
16743
|
+
* rules: renameRules(
|
|
16744
|
+
* {
|
|
16745
|
+
* "@typescript-eslint/indent": "error",
|
|
16746
|
+
* },
|
|
16747
|
+
* { "@typescript-eslint": "ts" },
|
|
16748
|
+
* ),
|
|
16749
|
+
* },
|
|
16750
|
+
* ];
|
|
16751
|
+
* ```
|
|
16752
|
+
*/
|
|
16753
|
+
declare function renameRules(rules: Record<string, any>, map: Record<string, string>): Record<string, any>;
|
|
16754
|
+
/**
|
|
16755
|
+
* Rename plugin names a flat configs array
|
|
16756
|
+
*
|
|
16757
|
+
* @example
|
|
16758
|
+
* ```ts
|
|
16759
|
+
* import { renamePluginInConfigs } from "@ncontiero/eslint-config";
|
|
16760
|
+
* import someConfigs from "./some-configs";
|
|
16761
|
+
*
|
|
16762
|
+
* export default renamePluginInConfigs(someConfigs, {
|
|
16763
|
+
* "@typescript-eslint": "ts",
|
|
16764
|
+
* });
|
|
16765
|
+
* ```
|
|
16766
|
+
*/
|
|
16767
|
+
declare function renamePluginInConfigs(configs: FlatConfigItem[], map: Record<string, string>): FlatConfigItem[];
|
|
16773
16768
|
declare function toArray<T>(value: T | T[]): T[];
|
|
16774
16769
|
//#endregion
|
|
16775
|
-
export { Awaitable, FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_REACT, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML, HTMLOptions, OptionsConfig, OptionsFiles, OptionsHasNextJs, OptionsHasRegexp, OptionsHasTanStackReactQuery, OptionsHasTypeScript, OptionsOverrides, OptionsTailwindCSS, OptionsTypeScriptParserOptions, OptionsTypescript, OptionsUnicorn, PrettierOptions, ResolvedOptions, Rules, StyleConfig, StyleOptions, combine, command, comments, composer, deMorgan, ensurePackages, getOverrides, hasNextJs, hasReact, hasTailwind, hasTanStackReactQuery, hasTypeScript, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, ncontiero, nextJs, node, parserPlain, perfectionist, prettier, promise, react, regexp, resolveSubOptions, restrictedSyntaxJs, sortPackageJson, sortPnpmWorkspace, sortTsconfig, tailwindcss, toArray, toml, typescript, unicorn, yml };
|
|
16770
|
+
export { Awaitable, ComposerOptions, FlatConfigItem, GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_REACT, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML, HTMLOptions, OptionsConfig, OptionsFiles, OptionsHasNextJs, OptionsHasRegexp, OptionsHasTanStackReactQuery, OptionsHasTypeScript, OptionsOverrides, OptionsTailwindCSS, OptionsTypeScriptParserOptions, OptionsTypescript, OptionsUnicorn, PrettierOptions, ResolvedOptions, Rules, StyleConfig, StyleOptions, combine, command, comments, composer, deMorgan, defaultPluginRenaming, ensurePackages, getOverrides, hasNextJs, hasReact, hasTailwind, hasTanStackReactQuery, hasTypeScript, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, ncontiero, nextJs, node, parserPlain, perfectionist, prettier, promise, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, restrictedSyntaxJs, sortPackageJson, sortPnpmWorkspace, sortTsconfig, tailwindcss, toArray, toml, typescript, unicorn, yml };
|
package/dist/index.mjs
CHANGED
|
@@ -153,12 +153,63 @@ function ensurePackages(packages) {
|
|
|
153
153
|
if (nonExistingPackages.length === 0) return;
|
|
154
154
|
throw new Error(`This package(s) are required for this config: ${nonExistingPackages.join(", ")}. Please install them.`);
|
|
155
155
|
}
|
|
156
|
-
async function composer(
|
|
156
|
+
async function composer({ items, pluginsNameMap }) {
|
|
157
157
|
let configs = [];
|
|
158
158
|
const flatResolved = (await Promise.all(items)).flat();
|
|
159
159
|
configs = [...configs, ...flatResolved];
|
|
160
|
+
if (pluginsNameMap) configs = renamePluginInConfigs(configs, pluginsNameMap);
|
|
160
161
|
return configs;
|
|
161
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Rename plugin prefixes in a rule object.
|
|
165
|
+
* Accepts a map of prefixes to rename.
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```ts
|
|
169
|
+
* import { renameRules } from "@ncontiero/eslint-config";
|
|
170
|
+
*
|
|
171
|
+
* export default [
|
|
172
|
+
* {
|
|
173
|
+
* rules: renameRules(
|
|
174
|
+
* {
|
|
175
|
+
* "@typescript-eslint/indent": "error",
|
|
176
|
+
* },
|
|
177
|
+
* { "@typescript-eslint": "ts" },
|
|
178
|
+
* ),
|
|
179
|
+
* },
|
|
180
|
+
* ];
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
function renameRules(rules, map) {
|
|
184
|
+
return Object.fromEntries(Object.entries(rules).map(([key, value]) => {
|
|
185
|
+
for (const [from, to] of Object.entries(map)) if (key.startsWith(`${from}/`)) return [to + key.slice(from.length), value];
|
|
186
|
+
return [key, value];
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Rename plugin names a flat configs array
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```ts
|
|
194
|
+
* import { renamePluginInConfigs } from "@ncontiero/eslint-config";
|
|
195
|
+
* import someConfigs from "./some-configs";
|
|
196
|
+
*
|
|
197
|
+
* export default renamePluginInConfigs(someConfigs, {
|
|
198
|
+
* "@typescript-eslint": "ts",
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
function renamePluginInConfigs(configs, map) {
|
|
203
|
+
return configs.map((i) => {
|
|
204
|
+
const clone = { ...i };
|
|
205
|
+
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
206
|
+
if (clone.plugins) clone.plugins = Object.fromEntries(Object.entries(clone.plugins).map(([key, value]) => {
|
|
207
|
+
if (key in map) return [map[key], value];
|
|
208
|
+
return [key, value];
|
|
209
|
+
}));
|
|
210
|
+
return clone;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
162
213
|
function toArray(value) {
|
|
163
214
|
return Array.isArray(value) ? value : [value];
|
|
164
215
|
}
|
|
@@ -959,7 +1010,7 @@ async function react(options = {}) {
|
|
|
959
1010
|
"react/no-leaked-conditional-rendering": "error",
|
|
960
1011
|
"react/no-missing-component-display-name": "warn",
|
|
961
1012
|
"react/no-unstable-context-value": "warn",
|
|
962
|
-
"react/no-unstable-default-props": "
|
|
1013
|
+
"react/no-unstable-default-props": "warn",
|
|
963
1014
|
"react/no-unused-props": "warn",
|
|
964
1015
|
"react/refs": "warn",
|
|
965
1016
|
...overrides
|
|
@@ -1557,6 +1608,7 @@ const flatConfigProps = [
|
|
|
1557
1608
|
"rules",
|
|
1558
1609
|
"settings"
|
|
1559
1610
|
];
|
|
1611
|
+
const defaultPluginRenaming = { "@eslint-react": "react" };
|
|
1560
1612
|
function resolveSubOptions(options, key) {
|
|
1561
1613
|
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
1562
1614
|
}
|
|
@@ -1636,7 +1688,10 @@ function ncontiero(options = {}, ...userConfigs) {
|
|
|
1636
1688
|
return acc;
|
|
1637
1689
|
}, {});
|
|
1638
1690
|
if (Object.keys(fusedConfig).length > 0) configs.push([fusedConfig]);
|
|
1639
|
-
return composer(
|
|
1691
|
+
return composer({
|
|
1692
|
+
items: [...configs, ...userConfigs],
|
|
1693
|
+
pluginsNameMap: defaultPluginRenaming
|
|
1694
|
+
});
|
|
1640
1695
|
}
|
|
1641
1696
|
//#endregion
|
|
1642
|
-
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_REACT, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML, combine, command, comments, composer, deMorgan, ensurePackages, getOverrides, hasNextJs, hasReact, hasTailwind, hasTanStackReactQuery, hasTypeScript, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, ncontiero, nextJs, node, parserPlain, perfectionist, prettier, promise, react, regexp, resolveSubOptions, restrictedSyntaxJs, sortPackageJson, sortPnpmWorkspace, sortTsconfig, tailwindcss, toArray, toml, typescript, unicorn, yml };
|
|
1697
|
+
export { GLOB_ALL_SRC, GLOB_CSS, GLOB_DIST, GLOB_EXCLUDE, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_LOCKFILE, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_NODE_MODULES, GLOB_POSTCSS, GLOB_REACT, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_YAML, combine, command, comments, composer, deMorgan, defaultPluginRenaming, ensurePackages, getOverrides, hasNextJs, hasReact, hasTailwind, hasTanStackReactQuery, hasTypeScript, html, ignores, imports, interopDefault, javascript, jsdoc, jsonc, markdown, ncontiero, nextJs, node, parserPlain, perfectionist, prettier, promise, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, restrictedSyntaxJs, sortPackageJson, sortPnpmWorkspace, sortTsconfig, tailwindcss, toArray, toml, typescript, unicorn, yml };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncontiero/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.3.0-beta.
|
|
4
|
+
"version": "7.3.0-beta.2",
|
|
5
5
|
"packageManager": "pnpm@10.33.2",
|
|
6
6
|
"description": "Nicolas's ESLint config.",
|
|
7
7
|
"author": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
|
|
55
|
-
"@eslint-react/eslint-plugin": "
|
|
55
|
+
"@eslint-react/eslint-plugin": "5.5.1-beta.1",
|
|
56
56
|
"@eslint/markdown": "^8.0.1",
|
|
57
57
|
"@html-eslint/eslint-plugin": "^0.59.0",
|
|
58
58
|
"@html-eslint/parser": "^0.59.0",
|