@kristijorgji/eslint-config-react-typescript 1.0.0 → 2.1.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/README.md +32 -2
- package/dist/create-react-config.d.ts +3 -0
- package/dist/create-react-config.d.ts.map +1 -1
- package/dist/create-react-config.js +21 -3
- package/dist/create-react-config.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx-props.d.ts +22 -0
- package/dist/jsx-props.d.ts.map +1 -0
- package/dist/jsx-props.js +37 -0
- package/dist/jsx-props.js.map +1 -0
- package/dist/shared.d.ts +4 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +7 -3
- package/dist/shared.js.map +1 -1
- package/package.json +14 -11
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ pnpm add -D @kristijorgji/eslint-config-react-typescript \
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Framework plugins are **optional peers** — only install what your variant needs.
|
|
22
|
+
`eslint-plugin-perfectionist` is a **dependency** of this package (JSX prop order).
|
|
22
23
|
|
|
23
24
|
## Usage
|
|
24
25
|
|
|
@@ -30,6 +31,7 @@ export default await createReactConfig({
|
|
|
30
31
|
variant: 'vite',
|
|
31
32
|
tsconfigRootDir: import.meta.dirname,
|
|
32
33
|
storybook: true,
|
|
34
|
+
prettier: 'prettierrc',
|
|
33
35
|
});
|
|
34
36
|
```
|
|
35
37
|
|
|
@@ -41,13 +43,41 @@ export default await createReactConfig({
|
|
|
41
43
|
| `tsconfigRootDir` | Required for type-aware rules |
|
|
42
44
|
| `storybook` | Vite only — Storybook flat recommended |
|
|
43
45
|
| `a11y` | Optional `eslint-plugin-jsx-a11y` |
|
|
44
|
-
|
|
|
46
|
+
| `jsxProps` | Options for `perfectionist/sort-jsx-props` (shallow merge); `false` disables |
|
|
47
|
+
| plus | All `createTypescriptConfig` options (`prettier`, `importOrder`, `sortImports`, `codeQuality`, `explicitTypes`, …) |
|
|
48
|
+
|
|
49
|
+
Opt-in TypeScript groups (`codeQuality`, `explicitTypes`) are documented on
|
|
50
|
+
[`@kristijorgji/eslint-config-typescript`](https://www.npmjs.com/package/@kristijorgji/eslint-config-typescript).
|
|
51
|
+
When `explicitTypes` enables `explicit-function-return-type`, this factory turns
|
|
52
|
+
that rule **off** for `**/*.{tsx,jsx}` so JSX return types stay inferred while
|
|
53
|
+
`.ts` helpers remain annotated.
|
|
45
54
|
|
|
46
55
|
### Shared React rules
|
|
47
56
|
|
|
48
57
|
- `eslint-plugin-react-hooks` / `react-refresh`
|
|
49
|
-
- `
|
|
58
|
+
- `perfectionist/sort-jsx-props` (ranked identity props, then unknown, callbacks last)
|
|
59
|
+
- `kj/no-single-export-barrel`
|
|
50
60
|
- `componentExtraction()` (`kj/no-multi-comp` + line limits, warn)
|
|
51
61
|
|
|
62
|
+
### Standalone JSX prop config
|
|
63
|
+
|
|
64
|
+
Adopters with a custom React preset (for example React Native) can compose without
|
|
65
|
+
the full factory:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
import { createJsxPropsConfig } from '@kristijorgji/eslint-config-react-typescript';
|
|
69
|
+
|
|
70
|
+
export default [
|
|
71
|
+
createJsxPropsConfig(),
|
|
72
|
+
];
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Rule inventory snapshots
|
|
76
|
+
|
|
77
|
+
`tests/rule-inventory.test.ts` snapshots enabled rule IDs for the vite and next
|
|
78
|
+
variants (and storybook-prefixed IDs when `storybook: true`). Failures on
|
|
79
|
+
upstream plugin bumps are an **intentional review gate** — update the snapshot
|
|
80
|
+
only after confirming the new rules are wanted.
|
|
81
|
+
|
|
52
82
|
Rewritten from the legacy `eslint-config-react-app` shareable config
|
|
53
83
|
([`8c090ded`](https://github.com/kristijorgji/eslint-config-react-typescript/commit/8c090ded195c4c957cee7e24b3b5b024ad6120f9)) — not a port of that lineage.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type CreateTypescriptConfigOptions } from '@kristijorgji/eslint-config-typescript';
|
|
2
2
|
import type { Linter } from 'eslint';
|
|
3
|
+
import type { SortJsxPropsOptions } from './jsx-props.js';
|
|
3
4
|
export type ReactConfigVariant = 'vite' | 'next';
|
|
4
5
|
export interface CreateReactConfigOptions extends CreateTypescriptConfigOptions {
|
|
5
6
|
/** Framework variant. Required. */
|
|
@@ -12,6 +13,8 @@ export interface CreateReactConfigOptions extends CreateTypescriptConfigOptions
|
|
|
12
13
|
a11y?: boolean;
|
|
13
14
|
/** Extra ignores passed to `componentExtraction`. */
|
|
14
15
|
extractionIgnores?: string[];
|
|
16
|
+
/** `false` disables JSX prop sorting; an object shallow-merges over package defaults. */
|
|
17
|
+
jsxProps?: false | SortJsxPropsOptions;
|
|
15
18
|
}
|
|
16
19
|
/**
|
|
17
20
|
* Flat ESLint config factory for React TypeScript apps.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-react-config.d.ts","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"create-react-config.d.ts","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,6BAA6B,EAEnC,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAa1D,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEjD,MAAM,WAAW,wBAAyB,SAAQ,6BAA6B;IAC7E,mCAAmC;IACnC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,qFAAqF;IACrF,eAAe,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yFAAyF;IACzF,QAAQ,CAAC,EAAE,KAAK,GAAG,mBAAmB,CAAC;CACxC;AA6GD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAuC1B"}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { createTypescriptConfig, } from '@kristijorgji/eslint-config-typescript';
|
|
1
|
+
import { createTypescriptConfig, defaultExplicitTypesOptions, } from '@kristijorgji/eslint-config-typescript';
|
|
2
2
|
import { createSharedReactConfigs } from './shared.js';
|
|
3
|
+
function isFunctionReturnTypeEnabled(setting) {
|
|
4
|
+
if (setting === undefined || setting === false) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
if (setting === true) {
|
|
8
|
+
return defaultExplicitTypesOptions.functionReturnType;
|
|
9
|
+
}
|
|
10
|
+
return setting.functionReturnType ?? defaultExplicitTypesOptions.functionReturnType;
|
|
11
|
+
}
|
|
3
12
|
function asPlugin(mod) {
|
|
4
13
|
const resolved = mod;
|
|
5
14
|
if (resolved && typeof resolved === 'object' && 'default' in resolved && resolved.default) {
|
|
@@ -89,14 +98,23 @@ async function loadA11yConfig() {
|
|
|
89
98
|
* Async so framework plugins can be optional peers loaded via dynamic `import()`.
|
|
90
99
|
*/
|
|
91
100
|
export async function createReactConfig(options) {
|
|
92
|
-
const { variant, tsconfigRootDir, storybook = false, a11y = false, extractionIgnores, ...tsOptions } = options;
|
|
101
|
+
const { variant, tsconfigRootDir, storybook = false, a11y = false, extractionIgnores, jsxProps, ...tsOptions } = options;
|
|
93
102
|
const configs = [
|
|
94
103
|
...createTypescriptConfig({
|
|
95
104
|
...tsOptions,
|
|
96
105
|
tsconfigRootDir,
|
|
97
106
|
}),
|
|
98
|
-
...createSharedReactConfigs({ extractionIgnores }),
|
|
107
|
+
...createSharedReactConfigs({ extractionIgnores, jsxProps }),
|
|
99
108
|
];
|
|
109
|
+
// JSX return types are inferred; keep explicit-function-return-type for .ts only.
|
|
110
|
+
if (isFunctionReturnTypeEnabled(tsOptions.explicitTypes)) {
|
|
111
|
+
configs.push({
|
|
112
|
+
files: ['**/*.{tsx,jsx}'],
|
|
113
|
+
rules: {
|
|
114
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
100
118
|
if (variant === 'vite') {
|
|
101
119
|
configs.push(...(await loadVitePlugins({ storybook, a11y })));
|
|
102
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-react-config.js","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"create-react-config.js","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,2BAA2B,GAG5B,MAAM,wCAAwC,CAAC;AAIhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,SAAS,2BAA2B,CAAC,OAAwC;IAC3E,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,2BAA2B,CAAC,kBAAkB,CAAC;IACxD,CAAC;IACD,OAAO,OAAO,CAAC,kBAAkB,IAAI,2BAA2B,CAAC,kBAAkB,CAAC;AACtF,CAAC;AAqBD,SAAS,QAAQ,CAAC,GAAY;IAC5B,MAAM,QAAQ,GAAG,GAAsC,CAAC;IACxD,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAAO,EAAE,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,MAAM,eAAe,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC;SAAM,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,MAAM,WAAW,GAAU,OAAO,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { createReactConfig, type CreateReactConfigOptions, type ReactConfigVariant, } from './create-react-config.js';
|
|
2
|
+
export { createJsxPropsConfig, defaultJsxPropsOptions, type SortJsxPropsCustomGroup, type SortJsxPropsOptions, } from './jsx-props.js';
|
|
2
3
|
export { createSharedReactConfigs } from './shared.js';
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,sBAAsB,GAGvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
export interface SortJsxPropsCustomGroup {
|
|
3
|
+
groupName: string;
|
|
4
|
+
elementNamePattern?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SortJsxPropsOptions {
|
|
7
|
+
type?: 'alphabetical' | 'natural' | 'line-length' | 'unsorted';
|
|
8
|
+
order?: 'asc' | 'desc';
|
|
9
|
+
ignoreCase?: boolean;
|
|
10
|
+
groups?: (string | string[])[];
|
|
11
|
+
customGroups?: SortJsxPropsCustomGroup[];
|
|
12
|
+
partitionByNewLine?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/** JSX prop order: ranked identity props first, then unknown props, callbacks last. */
|
|
15
|
+
export declare const defaultJsxPropsOptions: SortJsxPropsOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Standalone flat-config block for JSX prop order. Exported so consumers with their
|
|
18
|
+
* own React preset (for example React Native) can compose it without the full factory.
|
|
19
|
+
* Top-level option keys shallow-merge over {@link defaultJsxPropsOptions} (arrays replace).
|
|
20
|
+
*/
|
|
21
|
+
export declare function createJsxPropsConfig(options?: SortJsxPropsOptions): Linter.Config;
|
|
22
|
+
//# sourceMappingURL=jsx-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-props.d.ts","sourceRoot":"","sources":["../src/jsx-props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;IAC/D,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACzC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,uFAAuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,mBAapC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAcjF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import perfectionist from 'eslint-plugin-perfectionist';
|
|
2
|
+
/** JSX prop order: ranked identity props first, then unknown props, callbacks last. */
|
|
3
|
+
export const defaultJsxPropsOptions = {
|
|
4
|
+
type: 'alphabetical',
|
|
5
|
+
order: 'asc',
|
|
6
|
+
ignoreCase: true,
|
|
7
|
+
groups: ['testid', 'key', 'ref', 'id', 'name', 'unknown', 'callback'],
|
|
8
|
+
customGroups: [
|
|
9
|
+
{ groupName: 'testid', elementNamePattern: '^(data-testid|testID)$' },
|
|
10
|
+
{ groupName: 'key', elementNamePattern: '^key$' },
|
|
11
|
+
{ groupName: 'ref', elementNamePattern: '^ref$' },
|
|
12
|
+
{ groupName: 'id', elementNamePattern: '^id$' },
|
|
13
|
+
{ groupName: 'name', elementNamePattern: '^name$' },
|
|
14
|
+
{ groupName: 'callback', elementNamePattern: '^on.+' },
|
|
15
|
+
],
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Standalone flat-config block for JSX prop order. Exported so consumers with their
|
|
19
|
+
* own React preset (for example React Native) can compose it without the full factory.
|
|
20
|
+
* Top-level option keys shallow-merge over {@link defaultJsxPropsOptions} (arrays replace).
|
|
21
|
+
*/
|
|
22
|
+
export function createJsxPropsConfig(options) {
|
|
23
|
+
return {
|
|
24
|
+
files: ['**/*.{ts,tsx}'],
|
|
25
|
+
plugins: { perfectionist },
|
|
26
|
+
rules: {
|
|
27
|
+
'perfectionist/sort-jsx-props': [
|
|
28
|
+
'error',
|
|
29
|
+
{
|
|
30
|
+
...defaultJsxPropsOptions,
|
|
31
|
+
...options,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=jsx-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-props.js","sourceRoot":"","sources":["../src/jsx-props.ts"],"names":[],"mappings":"AACA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAgBxD,uFAAuF;AACvF,MAAM,CAAC,MAAM,sBAAsB,GAAwB;IACzD,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;IACrE,YAAY,EAAE;QACZ,EAAE,SAAS,EAAE,QAAQ,EAAE,kBAAkB,EAAE,wBAAwB,EAAE;QACrE,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE;QACjD,EAAE,SAAS,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE;QACjD,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE;QAC/C,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,QAAQ,EAAE;QACnD,EAAE,SAAS,EAAE,UAAU,EAAE,kBAAkB,EAAE,OAAO,EAAE;KACvD;CACF,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA6B;IAChE,OAAO;QACL,KAAK,EAAE,CAAC,eAAe,CAAC;QACxB,OAAO,EAAE,EAAE,aAAa,EAAE;QAC1B,KAAK,EAAE;YACL,8BAA8B,EAAE;gBAC9B,OAAO;gBACP;oBACE,GAAG,sBAAsB;oBACzB,GAAG,OAAO;iBACX;aACF;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { Linter } from 'eslint';
|
|
2
|
-
|
|
2
|
+
import { type SortJsxPropsOptions } from './jsx-props.js';
|
|
3
|
+
/** Shared React core: hooks, refresh, kj barrel/extraction rules, browser globals, JSX prop order. */
|
|
3
4
|
export declare function createSharedReactConfigs(options?: {
|
|
4
5
|
extractionIgnores?: string[];
|
|
6
|
+
/** `false` disables JSX prop sorting; an object shallow-merges over package defaults. */
|
|
7
|
+
jsxProps?: false | SortJsxPropsOptions;
|
|
5
8
|
}): Linter.Config[];
|
|
6
9
|
//# sourceMappingURL=shared.d.ts.map
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,OAAO,EAAwB,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,sGAAsG;AACtG,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,yFAAyF;IACzF,QAAQ,CAAC,EAAE,KAAK,GAAG,mBAAmB,CAAC;CACxC,GAAG,MAAM,CAAC,MAAM,EAAE,CA6ClB"}
|
package/dist/shared.js
CHANGED
|
@@ -2,7 +2,8 @@ import { componentExtraction, plugin as kjPlugin } from '@kristijorgji/eslint-pl
|
|
|
2
2
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
3
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
4
4
|
import globals from 'globals';
|
|
5
|
-
|
|
5
|
+
import { createJsxPropsConfig } from './jsx-props.js';
|
|
6
|
+
/** Shared React core: hooks, refresh, kj barrel/extraction rules, browser globals, JSX prop order. */
|
|
6
7
|
export function createSharedReactConfigs(options) {
|
|
7
8
|
const extractionIgnores = options?.extractionIgnores ?? [
|
|
8
9
|
'**/components/ui/**',
|
|
@@ -11,7 +12,7 @@ export function createSharedReactConfigs(options) {
|
|
|
11
12
|
'**/*.test.ts',
|
|
12
13
|
'**/*.stories.ts',
|
|
13
14
|
];
|
|
14
|
-
|
|
15
|
+
const configs = [
|
|
15
16
|
{
|
|
16
17
|
files: ['**/*.{ts,tsx}'],
|
|
17
18
|
languageOptions: {
|
|
@@ -34,7 +35,6 @@ export function createSharedReactConfigs(options) {
|
|
|
34
35
|
files: ['**/*.{ts,tsx}'],
|
|
35
36
|
plugins: { kj: kjPlugin },
|
|
36
37
|
rules: {
|
|
37
|
-
'kj/jsx-leading-prop-order': 'error',
|
|
38
38
|
'kj/no-single-export-barrel': 'error',
|
|
39
39
|
},
|
|
40
40
|
},
|
|
@@ -42,5 +42,9 @@ export function createSharedReactConfigs(options) {
|
|
|
42
42
|
ignores: extractionIgnores,
|
|
43
43
|
}),
|
|
44
44
|
];
|
|
45
|
+
if (options?.jsxProps !== false) {
|
|
46
|
+
configs.push(createJsxPropsConfig(options?.jsxProps));
|
|
47
|
+
}
|
|
48
|
+
return configs;
|
|
45
49
|
}
|
|
46
50
|
//# sourceMappingURL=shared.js.map
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,oBAAoB,EAA4B,MAAM,gBAAgB,CAAC;AAEhF,sGAAsG;AACtG,MAAM,UAAU,wBAAwB,CAAC,OAIxC;IACC,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI;QACtD,qBAAqB;QACrB,eAAe;QACf,kBAAkB;QAClB,cAAc;QACd,iBAAiB;KAClB,CAAC;IAEF,MAAM,OAAO,GAAoB;QAC/B;YACE,KAAK,EAAE,CAAC,eAAe,CAAC;YACxB,eAAe,EAAE;gBACf,OAAO,EAAE;oBACP,GAAG,OAAO,CAAC,OAAO;iBACnB;aACF;SACF;QACD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU;gBACzB,eAAe,EAAE,YAAY;aAC9B;YACD,KAAK,EAAE;gBACL,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK;gBACvC,sCAAsC,EAAE,CAAC,MAAM,EAAE,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAC;aAChF;SACF;QACD;YACE,KAAK,EAAE,CAAC,eAAe,CAAC;YACxB,OAAO,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE;YACzB,KAAK,EAAE;gBACL,4BAA4B,EAAE,OAAO;aACtC;SACF;QACD,GAAG,mBAAmB,CAAC;YACrB,OAAO,EAAE,iBAAiB;SAC3B,CAAC;KACH,CAAC;IAEF,IAAI,OAAO,EAAE,QAAQ,KAAK,KAAK,EAAE,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kristijorgji/eslint-config-react-typescript",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Flat ESLint React TypeScript config factory (vite | next) on @kristijorgji/eslint-config-typescript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"publishConfig": {
|
|
12
12
|
"access": "public",
|
|
13
|
-
"provenance":
|
|
13
|
+
"provenance": true
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
@@ -61,23 +61,26 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
+
"eslint-plugin-perfectionist": "^4.15.0",
|
|
64
65
|
"eslint-plugin-react-hooks": "^5",
|
|
65
66
|
"eslint-plugin-react-refresh": "^0.4",
|
|
66
|
-
"globals": "^
|
|
67
|
-
"@kristijorgji/eslint-config-typescript": "^1.
|
|
68
|
-
"@kristijorgji/eslint-plugin": "^0.
|
|
67
|
+
"globals": "^17",
|
|
68
|
+
"@kristijorgji/eslint-config-typescript": "^1.2.1",
|
|
69
|
+
"@kristijorgji/eslint-plugin": "^0.2.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
|
-
"@next/eslint-plugin-next": "^
|
|
72
|
-
"@types/node": "^
|
|
73
|
-
"
|
|
72
|
+
"@next/eslint-plugin-next": "^16",
|
|
73
|
+
"@types/node": "^26",
|
|
74
|
+
"@types/react": "^19.2.18",
|
|
75
|
+
"eslint": "^10",
|
|
74
76
|
"eslint-plugin-react": "^7",
|
|
75
|
-
"eslint-plugin-react-dom": "^
|
|
76
|
-
"eslint-plugin-react-x": "^
|
|
77
|
+
"eslint-plugin-react-dom": "^5",
|
|
78
|
+
"eslint-plugin-react-x": "^5",
|
|
77
79
|
"eslint-plugin-storybook": "^9",
|
|
78
80
|
"prettier": "^3",
|
|
81
|
+
"react": "^19.2.8",
|
|
79
82
|
"typescript": "^5",
|
|
80
|
-
"vitest": "^
|
|
83
|
+
"vitest": "^4"
|
|
81
84
|
},
|
|
82
85
|
"scripts": {
|
|
83
86
|
"build": "tsc -p tsconfig.json",
|