@kristijorgji/eslint-config-react-typescript 0.0.1 → 1.0.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/LICENSE +1 -1
- package/README.md +41 -26
- package/dist/create-react-config.d.ts +22 -0
- package/dist/create-react-config.d.ts.map +1 -0
- package/dist/create-react-config.js +112 -0
- package/dist/create-react-config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/shared.d.ts +6 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +46 -0
- package/dist/shared.js.map +1 -0
- package/package.json +83 -19
- package/index.js +0 -60
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,38 +1,53 @@
|
|
|
1
1
|
# @kristijorgji/eslint-config-react-typescript
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
3
|
+
Flat ESLint config factory for React + TypeScript apps. Builds on
|
|
4
|
+
[`@kristijorgji/eslint-config-typescript`](https://www.npmjs.com/package/@kristijorgji/eslint-config-typescript)
|
|
5
|
+
with `variant: 'vite' | 'next'`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Vite + Storybook example
|
|
11
|
+
pnpm add -D @kristijorgji/eslint-config-react-typescript \
|
|
12
|
+
eslint typescript prettier \
|
|
13
|
+
eslint-plugin-react-x eslint-plugin-react-dom eslint-plugin-storybook
|
|
14
|
+
|
|
15
|
+
# Next example
|
|
16
|
+
pnpm add -D @kristijorgji/eslint-config-react-typescript \
|
|
17
|
+
eslint typescript prettier \
|
|
18
|
+
eslint-plugin-react @next/eslint-plugin-next
|
|
11
19
|
```
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
Framework plugins are **optional peers** — only install what your variant needs.
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
Add the following to your `.eslintrc.js`:
|
|
17
|
-
```js
|
|
18
|
-
module.exports = {
|
|
19
|
-
extends: ['@kristijorgji/eslint-config-react-typescript'],
|
|
20
|
-
};
|
|
23
|
+
## Usage
|
|
21
24
|
|
|
25
|
+
```js
|
|
26
|
+
// eslint.config.js
|
|
27
|
+
import { createReactConfig } from '@kristijorgji/eslint-config-react-typescript';
|
|
28
|
+
|
|
29
|
+
export default await createReactConfig({
|
|
30
|
+
variant: 'vite',
|
|
31
|
+
tsconfigRootDir: import.meta.dirname,
|
|
32
|
+
storybook: true,
|
|
33
|
+
});
|
|
22
34
|
```
|
|
23
35
|
|
|
24
|
-
|
|
25
|
-
More info on how to develop your custom eslint config can be found here: https://eslint.org/docs/developer-guide/shareable-configs
|
|
26
|
-
|
|
27
|
-
To develop locally you can install with `yarn add --dev pathtolocalfile` example
|
|
28
|
-
`yarn add --dev /Users/kristi.jorgji/Desktop/fl-lite/eslint-config-react-typescript`
|
|
29
|
-
|
|
30
|
-
You need to run the above command after every plugin change.
|
|
36
|
+
### Options
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
| Option | Description |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `variant` | `'vite'` or `'next'` (required) |
|
|
41
|
+
| `tsconfigRootDir` | Required for type-aware rules |
|
|
42
|
+
| `storybook` | Vite only — Storybook flat recommended |
|
|
43
|
+
| `a11y` | Optional `eslint-plugin-jsx-a11y` |
|
|
44
|
+
| plus | All `createTypescriptConfig` options |
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
### Shared React rules
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
- `eslint-plugin-react-hooks` / `react-refresh`
|
|
49
|
+
- `kj/jsx-leading-prop-order`, `kj/no-single-export-barrel`
|
|
50
|
+
- `componentExtraction()` (`kj/no-multi-comp` + line limits, warn)
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
Rewritten from the legacy `eslint-config-react-app` shareable config
|
|
53
|
+
([`8c090ded`](https://github.com/kristijorgji/eslint-config-react-typescript/commit/8c090ded195c4c957cee7e24b3b5b024ad6120f9)) — not a port of that lineage.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type CreateTypescriptConfigOptions } from '@kristijorgji/eslint-config-typescript';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
export type ReactConfigVariant = 'vite' | 'next';
|
|
4
|
+
export interface CreateReactConfigOptions extends CreateTypescriptConfigOptions {
|
|
5
|
+
/** Framework variant. Required. */
|
|
6
|
+
variant: ReactConfigVariant;
|
|
7
|
+
/** Directory containing the consumer's `tsconfig.json`. Required for typed rules. */
|
|
8
|
+
tsconfigRootDir: string;
|
|
9
|
+
/** Include Storybook flat recommended (vite variant). Defaults to false. */
|
|
10
|
+
storybook?: boolean;
|
|
11
|
+
/** Include `eslint-plugin-jsx-a11y` recommended. Defaults to false. */
|
|
12
|
+
a11y?: boolean;
|
|
13
|
+
/** Extra ignores passed to `componentExtraction`. */
|
|
14
|
+
extractionIgnores?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Flat ESLint config factory for React TypeScript apps.
|
|
18
|
+
*
|
|
19
|
+
* Async so framework plugins can be optional peers loaded via dynamic `import()`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createReactConfig(options: CreateReactConfigOptions): Promise<Linter.Config[]>;
|
|
22
|
+
//# sourceMappingURL=create-react-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-react-config.d.ts","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,6BAA6B,EACnC,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI7C,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;CAC9B;AA6GD;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CA4B1B"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createTypescriptConfig, } from '@kristijorgji/eslint-config-typescript';
|
|
2
|
+
import { createSharedReactConfigs } from './shared.js';
|
|
3
|
+
function asPlugin(mod) {
|
|
4
|
+
const resolved = mod;
|
|
5
|
+
if (resolved && typeof resolved === 'object' && 'default' in resolved && resolved.default) {
|
|
6
|
+
return resolved.default;
|
|
7
|
+
}
|
|
8
|
+
return resolved;
|
|
9
|
+
}
|
|
10
|
+
function pluginConfigs(plugin) {
|
|
11
|
+
return (plugin.configs ?? {});
|
|
12
|
+
}
|
|
13
|
+
function rulesFrom(value) {
|
|
14
|
+
if (value && typeof value === 'object' && 'rules' in value) {
|
|
15
|
+
return (value.rules ?? {});
|
|
16
|
+
}
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
async function loadVitePlugins(options) {
|
|
20
|
+
const configs = [];
|
|
21
|
+
const reactX = asPlugin(await import('eslint-plugin-react-x'));
|
|
22
|
+
const reactDom = asPlugin(await import('eslint-plugin-react-dom'));
|
|
23
|
+
const reactXConfigs = pluginConfigs(reactX);
|
|
24
|
+
const reactDomConfigs = pluginConfigs(reactDom);
|
|
25
|
+
configs.push({
|
|
26
|
+
files: ['**/*.{ts,tsx}'],
|
|
27
|
+
plugins: {
|
|
28
|
+
'react-x': reactX,
|
|
29
|
+
'react-dom': reactDom,
|
|
30
|
+
},
|
|
31
|
+
rules: {
|
|
32
|
+
...rulesFrom(reactXConfigs['recommended-typescript']),
|
|
33
|
+
...rulesFrom(reactDomConfigs.recommended),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (options.storybook) {
|
|
37
|
+
const storybook = asPlugin(await import('eslint-plugin-storybook'));
|
|
38
|
+
const flat = pluginConfigs(storybook)['flat/recommended'];
|
|
39
|
+
if (Array.isArray(flat)) {
|
|
40
|
+
configs.push(...flat);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (options.a11y) {
|
|
44
|
+
configs.push(await loadA11yConfig());
|
|
45
|
+
}
|
|
46
|
+
return configs;
|
|
47
|
+
}
|
|
48
|
+
async function loadNextPlugins(options) {
|
|
49
|
+
const configs = [];
|
|
50
|
+
const react = asPlugin(await import('eslint-plugin-react'));
|
|
51
|
+
const nextPlugin = asPlugin(await import('@next/eslint-plugin-next'));
|
|
52
|
+
const reactConfigs = pluginConfigs(react);
|
|
53
|
+
const flat = (reactConfigs.flat ?? {});
|
|
54
|
+
const nextConfigs = pluginConfigs(nextPlugin);
|
|
55
|
+
configs.push({
|
|
56
|
+
plugins: { react },
|
|
57
|
+
settings: { react: { version: 'detect' } },
|
|
58
|
+
rules: {
|
|
59
|
+
...rulesFrom(flat.recommended),
|
|
60
|
+
...rulesFrom(flat['jsx-runtime']),
|
|
61
|
+
'react/prop-types': 'off',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
configs.push({
|
|
65
|
+
plugins: { '@next/next': nextPlugin },
|
|
66
|
+
rules: {
|
|
67
|
+
...rulesFrom(nextConfigs.recommended),
|
|
68
|
+
...rulesFrom(nextConfigs['core-web-vitals']),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (options.a11y) {
|
|
72
|
+
configs.push(await loadA11yConfig());
|
|
73
|
+
}
|
|
74
|
+
return configs;
|
|
75
|
+
}
|
|
76
|
+
async function loadA11yConfig() {
|
|
77
|
+
const jsxA11y = asPlugin(await import('eslint-plugin-jsx-a11y'));
|
|
78
|
+
const flatConfigs = jsxA11y
|
|
79
|
+
.flatConfigs;
|
|
80
|
+
return {
|
|
81
|
+
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
|
|
82
|
+
plugins: { 'jsx-a11y': jsxA11y },
|
|
83
|
+
rules: { ...rulesFrom(flatConfigs?.recommended) },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Flat ESLint config factory for React TypeScript apps.
|
|
88
|
+
*
|
|
89
|
+
* Async so framework plugins can be optional peers loaded via dynamic `import()`.
|
|
90
|
+
*/
|
|
91
|
+
export async function createReactConfig(options) {
|
|
92
|
+
const { variant, tsconfigRootDir, storybook = false, a11y = false, extractionIgnores, ...tsOptions } = options;
|
|
93
|
+
const configs = [
|
|
94
|
+
...createTypescriptConfig({
|
|
95
|
+
...tsOptions,
|
|
96
|
+
tsconfigRootDir,
|
|
97
|
+
}),
|
|
98
|
+
...createSharedReactConfigs({ extractionIgnores }),
|
|
99
|
+
];
|
|
100
|
+
if (variant === 'vite') {
|
|
101
|
+
configs.push(...(await loadVitePlugins({ storybook, a11y })));
|
|
102
|
+
}
|
|
103
|
+
else if (variant === 'next') {
|
|
104
|
+
configs.push(...(await loadNextPlugins({ a11y })));
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const _exhaustive = variant;
|
|
108
|
+
throw new Error(`Unknown React config variant: ${String(_exhaustive)}`);
|
|
109
|
+
}
|
|
110
|
+
return configs;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=create-react-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-react-config.js","sourceRoot":"","sources":["../src/create-react-config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAEvB,MAAM,wCAAwC,CAAC;AAGhD,OAAO,EAAE,wBAAwB,EAAE,MA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AC,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
ADDED
|
@@ -0,0 +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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +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"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Linter } from 'eslint';
|
|
2
|
+
/** Shared React core: hooks, refresh, kj JSX/barrel/extraction rules, browser globals. */
|
|
3
|
+
export declare function createSharedReactConfigs(options?: {
|
|
4
|
+
extractionIgnores?: string[];
|
|
5
|
+
}): Linter.Config[];
|
|
6
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +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,0FAA0F;AAC1F,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE;IACjD,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC9B,GAAG,MAAM,CAAC,MAAM,EAAE,CAwClB"}
|
package/dist/shared.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { componentExtraction, plugin as kjPlugin } from '@kristijorgji/eslint-plugin';
|
|
2
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
|
+
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
4
|
+
import globals from 'globals';
|
|
5
|
+
/** Shared React core: hooks, refresh, kj JSX/barrel/extraction rules, browser globals. */
|
|
6
|
+
export function createSharedReactConfigs(options) {
|
|
7
|
+
const extractionIgnores = options?.extractionIgnores ?? [
|
|
8
|
+
'**/components/ui/**',
|
|
9
|
+
'**/*.test.tsx',
|
|
10
|
+
'**/*.stories.tsx',
|
|
11
|
+
'**/*.test.ts',
|
|
12
|
+
'**/*.stories.ts',
|
|
13
|
+
];
|
|
14
|
+
return [
|
|
15
|
+
{
|
|
16
|
+
files: ['**/*.{ts,tsx}'],
|
|
17
|
+
languageOptions: {
|
|
18
|
+
globals: {
|
|
19
|
+
...globals.browser,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
plugins: {
|
|
25
|
+
'react-hooks': reactHooks,
|
|
26
|
+
'react-refresh': reactRefresh,
|
|
27
|
+
},
|
|
28
|
+
rules: {
|
|
29
|
+
...reactHooks.configs.recommended.rules,
|
|
30
|
+
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
files: ['**/*.{ts,tsx}'],
|
|
35
|
+
plugins: { kj: kjPlugin },
|
|
36
|
+
rules: {
|
|
37
|
+
'kj/jsx-leading-prop-order': 'error',
|
|
38
|
+
'kj/no-single-export-barrel': 'error',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
...componentExtraction({
|
|
42
|
+
ignores: extractionIgnores,
|
|
43
|
+
}),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +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,0FAA0F;AAC1F,MAAM,UAAU,wBAAwB,CAAC,OAExC;IACC,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI;QACtD,qBAAqB;QACrB,eAAe;QACf,kBAAkB;QAClB,cAAc;QACd,iBAAiB;KAClB,CAAC;IAEF,OAAO;QACL;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,2BAA2B,EAAE,OAAO;gBACpC,4BAA4B,EAAE,OAAO;aACtC;SACF;QACD,GAAG,mBAAmB,CAAC;YACrB,OAAO,EAAE,iBAAiB;SAC3B,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,24 +1,88 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kristijorgji/eslint-config-react-typescript",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Flat ESLint React TypeScript config factory (vite | next) on @kristijorgji/eslint-config-typescript",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "kristijorgji",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=22.16.0"
|
|
10
|
+
},
|
|
5
11
|
"publishConfig": {
|
|
6
|
-
"access": "public"
|
|
12
|
+
"access": "public",
|
|
13
|
+
"provenance": false
|
|
7
14
|
},
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"eslint-config-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"react",
|
|
18
|
-
"typescript",
|
|
19
|
-
"eslint",
|
|
20
|
-
"prettier"
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/kristijorgji/js-devkit.git",
|
|
18
|
+
"directory": "packages/eslint-config-react-typescript"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
21
24
|
],
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@next/eslint-plugin-next": "^15 || ^16",
|
|
34
|
+
"eslint": "^9 || ^10",
|
|
35
|
+
"eslint-plugin-jsx-a11y": "^6",
|
|
36
|
+
"eslint-plugin-react": "^7",
|
|
37
|
+
"eslint-plugin-react-dom": "^1 || ^2",
|
|
38
|
+
"eslint-plugin-react-x": "^1 || ^2",
|
|
39
|
+
"eslint-plugin-storybook": "^0 || ^9 || ^10",
|
|
40
|
+
"prettier": "^3",
|
|
41
|
+
"typescript": "^5 || ^6"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"@next/eslint-plugin-next": {
|
|
45
|
+
"optional": true
|
|
46
|
+
},
|
|
47
|
+
"eslint-plugin-jsx-a11y": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"eslint-plugin-react": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"eslint-plugin-react-dom": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"eslint-plugin-react-x": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"eslint-plugin-storybook": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"eslint-plugin-react-hooks": "^5",
|
|
65
|
+
"eslint-plugin-react-refresh": "^0.4",
|
|
66
|
+
"globals": "^16",
|
|
67
|
+
"@kristijorgji/eslint-config-typescript": "^1.0.0",
|
|
68
|
+
"@kristijorgji/eslint-plugin": "^0.1.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@next/eslint-plugin-next": "^15",
|
|
72
|
+
"@types/node": "^22",
|
|
73
|
+
"eslint": "^9",
|
|
74
|
+
"eslint-plugin-react": "^7",
|
|
75
|
+
"eslint-plugin-react-dom": "^1",
|
|
76
|
+
"eslint-plugin-react-x": "^1",
|
|
77
|
+
"eslint-plugin-storybook": "^9",
|
|
78
|
+
"prettier": "^3",
|
|
79
|
+
"typescript": "^5",
|
|
80
|
+
"vitest": "^3"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "tsc -p tsconfig.json",
|
|
84
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
85
|
+
"test": "vitest run",
|
|
86
|
+
"test:watch": "vitest"
|
|
87
|
+
}
|
|
88
|
+
}
|
package/index.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
extends: [
|
|
3
|
-
'react-app',
|
|
4
|
-
'eslint:recommended',
|
|
5
|
-
'plugin:@typescript-eslint/recommended',
|
|
6
|
-
'plugin:import/errors',
|
|
7
|
-
'plugin:import/warnings',
|
|
8
|
-
'plugin:import/typescript',
|
|
9
|
-
'plugin:prettier/recommended',
|
|
10
|
-
],
|
|
11
|
-
rules: {
|
|
12
|
-
'prettier/prettier': [
|
|
13
|
-
'error',
|
|
14
|
-
{
|
|
15
|
-
semi: true,
|
|
16
|
-
trailingComma: 'es5',
|
|
17
|
-
singleQuote: true,
|
|
18
|
-
printWidth: 120,
|
|
19
|
-
tabWidth: 4,
|
|
20
|
-
useTabs: false,
|
|
21
|
-
bracketSpacing: true,
|
|
22
|
-
arrowParens: 'avoid',
|
|
23
|
-
endOfLine: "lf"
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
'import/no-anonymous-default-export': 'off',
|
|
27
|
-
'@typescript-eslint/ban-ts-comment': 'off',
|
|
28
|
-
'@typescript-eslint/no-non-null-assertion': 'warn',
|
|
29
|
-
'import/order': [
|
|
30
|
-
'error',
|
|
31
|
-
{
|
|
32
|
-
groups: ['builtin', 'external', 'internal', ['parent', 'sibling']],
|
|
33
|
-
pathGroups: [
|
|
34
|
-
{
|
|
35
|
-
pattern: 'react',
|
|
36
|
-
group: 'external',
|
|
37
|
-
position: 'before',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
pattern: '@/**',
|
|
41
|
-
group: 'external',
|
|
42
|
-
position: 'after',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
pathGroupsExcludedImportTypes: ['react'],
|
|
46
|
-
'newlines-between': 'always',
|
|
47
|
-
alphabetize: {
|
|
48
|
-
order: 'asc',
|
|
49
|
-
caseInsensitive: true,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
'sort-imports': [
|
|
54
|
-
'error',
|
|
55
|
-
{
|
|
56
|
-
ignoreDeclarationSort: true,
|
|
57
|
-
},
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
};
|