@vyriy/eslint-config 0.1.9
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 +21 -0
- package/README.md +85 -0
- package/index.d.ts +3 -0
- package/index.js +202 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Vyriy contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @vyriy/eslint-config
|
|
2
|
+
|
|
3
|
+
Shared ESLint flat config for Vyriy projects.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package provides the base ESLint setup used in Vyriy repositories for:
|
|
8
|
+
|
|
9
|
+
- TypeScript
|
|
10
|
+
- React
|
|
11
|
+
- Storybook
|
|
12
|
+
- Jest
|
|
13
|
+
- import resolution
|
|
14
|
+
- Prettier integration
|
|
15
|
+
- multiline object formatting for objects with more than three properties
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
With npm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install -D @vyriy/eslint-config eslint jiti
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
With Yarn:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
yarn add -D @vyriy/eslint-config eslint jiti
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Install `eslint` and `jiti` in the consumer project so CLI binaries are available.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Create `eslint.config.mjs` in your project:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
export { default } from '@vyriy/eslint-config';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If you need local overrides:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import baseConfig from '@vyriy/eslint-config';
|
|
45
|
+
|
|
46
|
+
export default [
|
|
47
|
+
...baseConfig,
|
|
48
|
+
{
|
|
49
|
+
rules: {
|
|
50
|
+
'no-console': 'warn',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Relative ESM Imports
|
|
57
|
+
|
|
58
|
+
Relative module specifiers must include the runtime file extension. TypeScript source that compiles to ESM should import local files with `.js` specifiers:
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
export * from './feature.js';
|
|
62
|
+
import { feature } from './feature.js';
|
|
63
|
+
export type { FeatureOptions } from './types.js';
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Extensionless relative specifiers are reported for static imports/exports, dynamic imports, `require`, and Jest module mocks:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { feature } from './feature';
|
|
70
|
+
jest.mock('./feature');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Multiline Objects
|
|
74
|
+
|
|
75
|
+
Object literals with more than three properties are reported when they are kept on one line.
|
|
76
|
+
This keeps larger value lists easier to scan:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const options = {
|
|
80
|
+
first,
|
|
81
|
+
second,
|
|
82
|
+
third,
|
|
83
|
+
fourth,
|
|
84
|
+
};
|
|
85
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import globals from 'globals';
|
|
3
|
+
import tsParser from '@typescript-eslint/parser';
|
|
4
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
|
+
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
6
|
+
import { createNodeResolver, importX } from 'eslint-plugin-import-x';
|
|
7
|
+
import jest from 'eslint-plugin-jest';
|
|
8
|
+
import reactHooks from 'eslint-plugin-react-hooks';
|
|
9
|
+
import { configs as storybookConfigs } from 'eslint-plugin-storybook';
|
|
10
|
+
import prettier from 'eslint-plugin-prettier';
|
|
11
|
+
import eslintReact from '@eslint-react/eslint-plugin';
|
|
12
|
+
const tsEslintPlugin = tsPlugin;
|
|
13
|
+
const jestPlugin = jest;
|
|
14
|
+
const prettierPlugin = prettier;
|
|
15
|
+
const storybookFlatRecommended = storybookConfigs['flat/recommended'];
|
|
16
|
+
const eslintReactRecommendedTypescript = eslintReact.configs['recommended-typescript'];
|
|
17
|
+
const reactHooksRecommended = reactHooks.configs.flat.recommended;
|
|
18
|
+
const importXPlugin = importX;
|
|
19
|
+
const importXRecommended = importX.flatConfigs.recommended;
|
|
20
|
+
const importXTypescript = importX.flatConfigs.typescript;
|
|
21
|
+
const extensionlessRelativeSpecifierPattern = String.raw `^\.{1,2}\/(?!.*\.(?:js|mjs|cjs|json|css|less|scss|sass|svg|md|mdx)$)`;
|
|
22
|
+
const extensionlessRelativeSpecifierMessage = 'Relative module specifiers must include a runtime file extension, usually .js.';
|
|
23
|
+
const multilineElementThreshold = 4;
|
|
24
|
+
const config = [
|
|
25
|
+
{
|
|
26
|
+
ignores: [
|
|
27
|
+
'dist/**',
|
|
28
|
+
'coverage/**',
|
|
29
|
+
'storybook-static/**',
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
js.configs.recommended,
|
|
33
|
+
{
|
|
34
|
+
languageOptions: {
|
|
35
|
+
ecmaVersion: 'latest',
|
|
36
|
+
sourceType: 'module',
|
|
37
|
+
globals: { ...globals.browser, ...globals.node },
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
files: ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'],
|
|
42
|
+
plugins: {
|
|
43
|
+
'import-x': importXPlugin,
|
|
44
|
+
},
|
|
45
|
+
settings: {
|
|
46
|
+
'import-x/resolver-next': [
|
|
47
|
+
createTypeScriptImportResolver({
|
|
48
|
+
project: './tsconfig.json',
|
|
49
|
+
alwaysTryTypes: true,
|
|
50
|
+
extensionAlias: {
|
|
51
|
+
'.js': [
|
|
52
|
+
'.ts',
|
|
53
|
+
'.tsx',
|
|
54
|
+
'.d.ts',
|
|
55
|
+
'.js',
|
|
56
|
+
],
|
|
57
|
+
'.mjs': [
|
|
58
|
+
'.mts',
|
|
59
|
+
'.mjs',
|
|
60
|
+
],
|
|
61
|
+
'.cjs': [
|
|
62
|
+
'.cts',
|
|
63
|
+
'.cjs',
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
createNodeResolver({
|
|
68
|
+
extensions: [
|
|
69
|
+
'.ts',
|
|
70
|
+
'.tsx',
|
|
71
|
+
'.mts',
|
|
72
|
+
'.cts',
|
|
73
|
+
'.js',
|
|
74
|
+
'.jsx',
|
|
75
|
+
'.mjs',
|
|
76
|
+
'.cjs',
|
|
77
|
+
'.json',
|
|
78
|
+
],
|
|
79
|
+
extensionAlias: {
|
|
80
|
+
'.js': [
|
|
81
|
+
'.ts',
|
|
82
|
+
'.tsx',
|
|
83
|
+
'.d.ts',
|
|
84
|
+
'.js',
|
|
85
|
+
],
|
|
86
|
+
'.mjs': [
|
|
87
|
+
'.mts',
|
|
88
|
+
'.mjs',
|
|
89
|
+
],
|
|
90
|
+
'.cjs': [
|
|
91
|
+
'.cts',
|
|
92
|
+
'.cjs',
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
rules: {
|
|
99
|
+
...importXRecommended.rules,
|
|
100
|
+
...importXTypescript.rules,
|
|
101
|
+
'no-restricted-syntax': [
|
|
102
|
+
'error',
|
|
103
|
+
{
|
|
104
|
+
selector: `ImportDeclaration[source.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
105
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
selector: `ExportNamedDeclaration[source.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
109
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
selector: `ExportAllDeclaration[source.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
113
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
selector: `ImportExpression[source.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
117
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
selector: `CallExpression[callee.type='Import'][arguments.0.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
121
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
selector: `CallExpression[callee.name='require'][arguments.0.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
125
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
selector: `CallExpression[callee.object.name='jest'][callee.property.name=/^(?:mock|doMock|unstable_mockModule)$/][arguments.0.value=/${extensionlessRelativeSpecifierPattern}/]`,
|
|
129
|
+
message: extensionlessRelativeSpecifierMessage,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
'object-curly-newline': [
|
|
133
|
+
'error',
|
|
134
|
+
{
|
|
135
|
+
ObjectExpression: {
|
|
136
|
+
minProperties: multilineElementThreshold,
|
|
137
|
+
multiline: true,
|
|
138
|
+
consistent: true,
|
|
139
|
+
},
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
files: ['**/*.{ts,tsx,mts,cts}'],
|
|
146
|
+
languageOptions: {
|
|
147
|
+
parser: tsParser,
|
|
148
|
+
parserOptions: {
|
|
149
|
+
project: [
|
|
150
|
+
'./tsconfig.json',
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
plugins: { '@typescript-eslint': tsEslintPlugin },
|
|
155
|
+
rules: {
|
|
156
|
+
...tsPlugin.configs['recommended-type-checked'].rules,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
files: [
|
|
161
|
+
'workspaces/**/*.{ts,tsx}',
|
|
162
|
+
'packages/**/*.{ts,tsx}',
|
|
163
|
+
'.storybook/*.{ts,tsx}',
|
|
164
|
+
'**/*.stories.{ts,tsx}',
|
|
165
|
+
],
|
|
166
|
+
...eslintReactRecommendedTypescript,
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
files: [
|
|
170
|
+
'workspaces/**/*.{ts,tsx}',
|
|
171
|
+
'packages/**/*.{ts,tsx}',
|
|
172
|
+
'.storybook/*.{ts,tsx}',
|
|
173
|
+
'**/*.stories.{ts,tsx}',
|
|
174
|
+
],
|
|
175
|
+
...reactHooksRecommended,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
files: ['**/*.test.{ts,tsx}'],
|
|
179
|
+
plugins: { jest: jestPlugin },
|
|
180
|
+
languageOptions: { globals: { ...globals.jest } },
|
|
181
|
+
rules: {
|
|
182
|
+
...jest.configs.recommended.rules,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
plugins: { prettier: prettierPlugin },
|
|
187
|
+
rules: {
|
|
188
|
+
'prettier/prettier': 'warn',
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
...storybookFlatRecommended,
|
|
192
|
+
{
|
|
193
|
+
files: [
|
|
194
|
+
'.bin/**/*.{ts,tsx}',
|
|
195
|
+
'.storybook/**/*.{ts,tsx}',
|
|
196
|
+
],
|
|
197
|
+
rules: {
|
|
198
|
+
'@typescript-eslint/require-await': 'off',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
export default config;
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vyriy/eslint-config",
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Shared ESLint config for Vyriy projects",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./index.js",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@eslint-react/eslint-plugin": "^5.7.5",
|
|
9
|
+
"@eslint/js": "^10.0.1",
|
|
10
|
+
"@typescript-eslint/eslint-plugin": "^8.59.2",
|
|
11
|
+
"@typescript-eslint/parser": "^8.59.2",
|
|
12
|
+
"eslint": "^10.3.0",
|
|
13
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
14
|
+
"eslint-plugin-import-x": "^4.16.2",
|
|
15
|
+
"eslint-plugin-jest": "^29.15.2",
|
|
16
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
17
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
18
|
+
"eslint-plugin-storybook": "^10.3.6",
|
|
19
|
+
"globals": "^17.6.0",
|
|
20
|
+
"jiti": "^2.7.0"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"types": "./index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"import": "./index.js",
|
|
28
|
+
"default": "./index.js"
|
|
29
|
+
},
|
|
30
|
+
"./index": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
32
|
+
"import": "./index.js",
|
|
33
|
+
"default": "./index.js"
|
|
34
|
+
},
|
|
35
|
+
"./index.js": {
|
|
36
|
+
"types": "./index.d.ts",
|
|
37
|
+
"import": "./index.js",
|
|
38
|
+
"default": "./index.js"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|