File tree Expand file tree Collapse file tree 10 files changed +112
-96
lines changed
eslint-plugin-react-debug/src
eslint-plugin-react-dom/src
eslint-plugin-react-naming-convention/src
eslint-plugin-react-web-api/src
eslint-plugin-react-x/src Expand file tree Collapse file tree 10 files changed +112
-96
lines changed Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as allConfig from "./configs/all" ;
44import { plugin } from "./plugin" ;
55
6- function toFlatConfig ( config : CompatibleConfig ) {
7- return {
8- ...config ,
9- plugins : {
10- "react-debug" : plugin ,
11- } ,
12- } ;
13- }
14-
15- function toLegacyConfig ( { rules } : CompatibleConfig ) {
16- return {
17- plugins : [ "react-debug" ] ,
18- rules,
19- } ;
20- }
6+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-debug" , plugin ) ;
217
228export default {
239 ...plugin ,
Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as recommendedConfig from "./configs/recommended" ;
44import { plugin } from "./plugin" ;
55
6- function toFlatConfig ( config : CompatibleConfig ) {
7- return {
8- ...config ,
9- plugins : {
10- "react-dom" : plugin ,
11- } ,
12- } ;
13- }
14-
15- function toLegacyConfig ( { rules } : CompatibleConfig ) {
16- return {
17- plugins : [ "react-dom" ] ,
18- rules,
19- } ;
20- }
6+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-dom" , plugin ) ;
217
228export default {
239 ...plugin ,
Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as recommendedConfig from "./configs/recommended" ;
44import { plugin } from "./plugin" ;
55
6- function toFlatConfig ( config : CompatibleConfig ) {
7- return {
8- ...config ,
9- plugins : {
10- "react-hooks-extra" : plugin ,
11- } ,
12- } ;
13- }
14-
15- function toLegacyConfig ( { rules } : CompatibleConfig ) {
16- return {
17- plugins : [ "react-hooks-extra" ] ,
18- rules,
19- } ;
20- }
6+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-hooks-extra" , plugin ) ;
217
228export default {
239 ...plugin ,
Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as recommendedConfig from "./configs/recommended" ;
44import { plugin } from "./plugin" ;
55
6- function toFlatConfig ( config : CompatibleConfig ) {
7- return {
8- ...config ,
9- plugins : {
10- "react-naming-convention" : plugin ,
11- } ,
12- } ;
13- }
14-
15- function toLegacyConfig ( { rules } : CompatibleConfig ) {
16- return {
17- plugins : [ "react-naming-convention" ] ,
18- rules,
19- } ;
20- }
6+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-naming-convention" , plugin ) ;
217
228export default {
239 ...plugin ,
Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as recommendedConfig from "./configs/recommended" ;
44import { plugin } from "./plugin" ;
55
6- function toFlatConfig ( config : CompatibleConfig ) {
7- return {
8- ...config ,
9- plugins : {
10- "react-web-api" : plugin ,
11- } ,
12- } ;
13- }
14-
15- function toLegacyConfig ( { rules } : CompatibleConfig ) {
16- return {
17- plugins : [ "react-web-api" ] ,
18- rules,
19- } ;
20- }
6+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-web-api" , plugin ) ;
217
228export default {
239 ...plugin ,
Original file line number Diff line number Diff line change 1- import type { CompatibleConfig } from "@eslint-react/kit " ;
1+ import { getConfigAdapters } from "@eslint-react/shared " ;
22
33import * as recommendedConfig from "./configs/recommended" ;
44import * as recommendedTypeCheckedConfig from "./configs/recommended-type-checked" ;
55import * as recommendedTypeScriptConfig from "./configs/recommended-typescript" ;
66import { plugin } from "./plugin" ;
77
8- function toFlatConfig ( config : CompatibleConfig ) {
9- return {
10- ...config ,
11- plugins : {
12- "react-x" : plugin ,
13- } ,
14- } ;
15- }
16-
17- function toLegacyConfig ( { rules } : CompatibleConfig ) {
18- return {
19- plugins : [ "react-x" ] ,
20- rules,
21- } ;
22- }
8+ const { toFlatConfig, toLegacyConfig } = getConfigAdapters ( "react-x" , plugin ) ;
239
2410export default {
2511 ...plugin ,
Original file line number Diff line number Diff line change 3636- [ coerceSettings] ( functions/coerceSettings.md )
3737- [ decodeESLintSettings] ( functions/decodeESLintSettings.md )
3838- [ decodeSettings] ( functions/decodeSettings.md )
39+ - [ getConfigAdapters] ( functions/getConfigAdapters.md )
3940- [ getReactVersion] ( functions/getReactVersion.md )
4041- [ getSettingsFromContext] ( functions/getSettingsFromContext.md )
4142- [ isESLintReactSettings] ( functions/isESLintReactSettings.md )
Original file line number Diff line number Diff line change 1+ [ ** @eslint-react/shared ** ] ( ../README.md )
2+
3+ ***
4+
5+ [ @eslint-react/shared ] ( ../README.md ) / getConfigAdapters
6+
7+ # Function: getConfigAdapters()
8+
9+ > ** getConfigAdapters** (` pluginName ` , ` plugin ` ): ` object `
10+
11+ ## Parameters
12+
13+ ### pluginName
14+
15+ ` string `
16+
17+ ### plugin
18+
19+ ` CompatiblePlugin `
20+
21+ ## Returns
22+
23+ ` object `
24+
25+ ### toFlatConfig()
26+
27+ > ** toFlatConfig** : (` config ` ) => ` object `
28+
29+ #### Parameters
30+
31+ ##### config
32+
33+ ` CompatibleConfig `
34+
35+ #### Returns
36+
37+ ` object `
38+
39+ ##### name?
40+
41+ > ` optional ` ** name** : ` string `
42+
43+ ##### plugins
44+
45+ > ** plugins** : ` object `
46+
47+ ###### Index Signature
48+
49+ \[ ` key ` : ` string ` \] : ` CompatiblePlugin `
50+
51+ ##### rules?
52+
53+ > ` optional ` ** rules** : [ ` Record ` ] ( https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type ) \< ` string ` , ` RuleConfig ` \< ` unknown ` [ ] \>\>
54+
55+ ##### settings?
56+
57+ > ` optional ` ** settings** : ` SettingsConfig `
58+
59+ ### toLegacyConfig()
60+
61+ > ** toLegacyConfig** : (` __namedParameters ` ) => ` object `
62+
63+ #### Parameters
64+
65+ ##### \_\_ namedParameters
66+
67+ ` CompatibleConfig `
68+
69+ #### Returns
70+
71+ ` object `
72+
73+ ##### plugins
74+
75+ > ** plugins** : ` string ` [ ]
76+
77+ ##### rules
78+
79+ > ** rules** : ` undefined ` \| [ ` Record ` ] ( https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type ) \< ` string ` , ` RuleConfig ` \< ` unknown ` [ ] \>\>
Original file line number Diff line number Diff line change 1+ import type { CompatibleConfig , CompatiblePlugin } from "@eslint-react/kit" ;
2+
3+ export function getConfigAdapters ( pluginName : string , plugin : CompatiblePlugin ) {
4+ function toFlatConfig ( config : CompatibleConfig ) {
5+ return {
6+ ...config ,
7+ plugins : {
8+ [ pluginName ] : plugin ,
9+ } ,
10+ } ;
11+ }
12+ function toLegacyConfig ( { rules } : CompatibleConfig ) {
13+ return {
14+ plugins : [ pluginName ] ,
15+ rules,
16+ } ;
17+ }
18+ return { toFlatConfig, toLegacyConfig } as const ;
19+ }
Original file line number Diff line number Diff line change 11export * from "./_id" ;
22export * from "./_require" ;
33export * from "./constants" ;
4+ export * from "./get-config-adapters" ;
45export * from "./get-doc-url" ;
56export * from "./get-react-version" ;
67export * from "./settings" ;
You can’t perform that action at this time.
0 commit comments