Skip to content

Commit 94f73ee

Browse files
committed
[ui] Upgrade to eslint 9
1 parent 5068b2c commit 94f73ee

79 files changed

Lines changed: 1222 additions & 654 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

js_modules/dagster-ui/packages/app-oss/.eslintrc.js

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import dagsterConfig from '@dagster-io/eslint-config';
2+
3+
// eslint-disable-next-line import/no-default-export
4+
export default [
5+
...dagsterConfig,
6+
{
7+
ignores: ['next-env.d.ts'],
8+
},
9+
];

js_modules/dagster-ui/packages/app-oss/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@typescript-eslint/eslint-plugin": "^8.44.0",
4242
"@typescript-eslint/parser": "^8.44.0",
4343
"@typescript/native-preview": "^7.0.0-dev.20251204.1",
44-
"eslint": "^8.57.1",
44+
"eslint": "^9.0.0",
4545
"eslint-plugin-import": "^2.31.0",
4646
"eslint-plugin-jest": "^26.4.6",
4747
"eslint-plugin-prettier": "^5.0.0",
@@ -57,8 +57,8 @@
5757
"scripts": {
5858
"start": "next dev",
5959
"build": "next build",
60-
"lint": "eslint src/ --ext=.tsx,.ts,.js --fix -c .eslintrc.js",
61-
"lint:ci": "eslint src/ --ext=.tsx,.ts,.js -c .eslintrc.js",
60+
"lint": "eslint src/ --fix",
61+
"lint:ci": "eslint src/",
6262
"test": "jest",
6363
"ts": "tsc -p .",
6464
"tsgo": "tsgo -p .",

js_modules/dagster-ui/packages/eslint-config/.eslintrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [2.0.0] - 2025-12-22
6+
7+
### BREAKING CHANGES
8+
9+
- **Requires ESLint 9.0.0 or higher** - Dropped ESLint 8 support
10+
- **Config format changed to ESLint flat config** - The package now exports a flat config array instead of a legacy .eslintrc object
11+
- **Consumers must migrate to flat config** - Projects using this config must:
12+
- Upgrade to ESLint 9: `yarn add -D eslint@^9.0.0`
13+
- Rename `.eslintrc.js` to `eslint.config.js`
14+
- Update config format (see README.md for migration guide)
15+
16+
### Added
17+
18+
- Full ESLint 9 flat config support with modern plugin integration
19+
- Plugin metadata (`meta.name` and `meta.version`) to custom `eslint-plugin-dagster-rules`
20+
- Dependency on `typescript-eslint` package for simplified flat config usage
21+
- Comprehensive migration guide in README.md
22+
23+
### Changed
24+
25+
- Main config (`index.js`) completely restructured to export flat config array
26+
- All plugin references updated to use flat config formats where available
27+
- Self-linting config converted from `.eslintrc.js` to `eslint.config.js`
28+
- Package scripts updated to use ESLint 9 CLI (removed `--ext` and `-c` flags)
29+
- Updated peer dependency: `eslint` from `^8.57.1` to `^9.0.0`
30+
- Updated dev dependency: `eslint` from `^8.57.1` to `^9.0.0`
31+
32+
### Migration Guide
33+
34+
See README.md for detailed migration instructions from v1.x to v2.0.0.
35+
36+
**Quick Migration Steps:**
37+
38+
1. Upgrade ESLint: `yarn add -D eslint@^9.0.0`
39+
2. Upgrade this package: `yarn add -D @dagster-io/eslint-config@^2.0.0`
40+
3. Rename `.eslintrc.js``eslint.config.js`
41+
4. Update config:
42+
43+
```javascript
44+
// Before (.eslintrc.js)
45+
module.exports = {
46+
extends: ['@dagster-io/eslint-config'],
47+
};
48+
49+
// After (eslint.config.js)
50+
const dagsterConfig = require('@dagster-io/eslint-config');
51+
module.exports = [...dagsterConfig];
52+
```
53+
54+
## [1.0.21] - Previous Release
55+
56+
See git history for changes prior to v2.0.0.
Lines changed: 258 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,278 @@
1-
## @dagster-io/eslint-config
1+
# @dagster-io/eslint-config
22

3-
Shared eslint configuration to be used in Dagster apps.
3+
Shared ESLint configuration for Dagster applications.
4+
5+
**Version 2.x+** requires **ESLint 9** and uses the flat config format.
6+
7+
For ESLint 8 support, use version 1.x.
8+
9+
## Installation
10+
11+
```bash
12+
yarn add -D @dagster-io/eslint-config eslint@^9.0.0 prettier@^3.3.3
13+
```
414

515
## Usage
616

7-
### 1. Install
17+
### ESLint 9 Flat Config (eslint.config.js)
18+
19+
Create an `eslint.config.js` file in your project root:
20+
21+
```javascript
22+
const dagsterConfig = require('@dagster-io/eslint-config');
23+
24+
module.exports = [
25+
...dagsterConfig,
26+
// Your custom overrides here
27+
{
28+
rules: {
29+
// Override specific rules
30+
},
31+
},
32+
];
33+
```
34+
35+
### With Ignores
36+
37+
```javascript
38+
const dagsterConfig = require('@dagster-io/eslint-config');
39+
40+
module.exports = [
41+
...dagsterConfig,
42+
{
43+
ignores: ['dist/**', 'build/**', '*.config.js'],
44+
},
45+
];
46+
```
47+
48+
### With Additional Plugins
49+
50+
```javascript
51+
const dagsterConfig = require('@dagster-io/eslint-config');
52+
const storybookPlugin = require('eslint-plugin-storybook');
53+
54+
module.exports = [
55+
...dagsterConfig,
56+
...storybookPlugin.configs['flat/recommended'],
57+
{
58+
// Additional configuration
59+
},
60+
];
61+
```
62+
63+
## Migration from v1 to v2
64+
65+
### Step 1: Upgrade Dependencies
866

967
```bash
10-
yarn -D add @dagster-io/eslint-config
68+
yarn add -D eslint@^9.0.0 @dagster-io/eslint-config@^2.0.0
1169
```
1270

13-
### 2. Add to your project's eslint configuration
71+
### Step 2: Rename Config File
1472

15-
```js
16-
// .eslintrc.js
73+
Rename `.eslintrc.js``eslint.config.js`
74+
75+
### Step 3: Update Config Format
76+
77+
**Before (.eslintrc.js):**
78+
79+
```javascript
1780
module.exports = {
1881
extends: ['@dagster-io/eslint-config'],
82+
ignorePatterns: ['dist/**'],
83+
overrides: [
84+
{
85+
files: ['*.test.ts'],
86+
rules: {
87+
'@typescript-eslint/no-explicit-any': 'off',
88+
},
89+
},
90+
],
1991
};
2092
```
2193

22-
If you are extending other configurations, put those first.
94+
**After (eslint.config.js):**
95+
96+
```javascript
97+
const dagsterConfig = require('@dagster-io/eslint-config');
98+
99+
module.exports = [
100+
...dagsterConfig,
101+
{
102+
ignores: ['dist/**'],
103+
},
104+
{
105+
files: ['*.test.ts'],
106+
rules: {
107+
'@typescript-eslint/no-explicit-any': 'off',
108+
},
109+
},
110+
];
111+
```
112+
113+
### Step 4: Update Scripts (if needed)
114+
115+
ESLint 9 with flat config auto-detects files and config location.
116+
117+
**Before:**
118+
119+
```json
120+
{
121+
"scripts": {
122+
"lint": "eslint . --ext .ts,.tsx -c .eslintrc.js"
123+
}
124+
}
125+
```
126+
127+
**After:**
128+
129+
```json
130+
{
131+
"scripts": {
132+
"lint": "eslint ."
133+
}
134+
}
135+
```
23136

24-
```js
137+
### Key Differences in Flat Config
138+
139+
1. **Config is an array** - Multiple config objects can be specified
140+
2. **No `extends`** - Configs are imported and spread: `...dagsterConfig`
141+
3. **Ignores replace ignorePatterns** - Use `ignores: ['pattern']` in config objects
142+
4. **Overrides are separate objects** - Each override is its own config object in the array
143+
5. **File patterns in `files` key** - Override specific files with `files: ['*.test.ts']`
144+
145+
## Custom Rules
146+
147+
This config includes custom Dagster-specific ESLint rules:
148+
149+
### `dagster-rules/missing-graphql-variables-type`
150+
151+
Ensures GraphQL queries and mutations specify the Variables type parameter.
152+
153+
**❌ Incorrect:**
154+
155+
```typescript
156+
const {data} = useQuery<SomeQuery>(SOME_QUERY);
157+
```
158+
159+
**✅ Correct:**
160+
161+
```typescript
162+
const {data} = useQuery<SomeQuery, SomeQueryVariables>(SOME_QUERY);
163+
```
164+
165+
### `dagster-rules/no-oss-imports`
166+
167+
Prevents relative imports of `.oss` files and enforces absolute path imports.
168+
169+
**❌ Incorrect:**
170+
171+
```typescript
172+
import {Component} from './Component.oss';
173+
```
174+
175+
**✅ Correct:**
176+
177+
```typescript
178+
import {Component} from 'shared/components/Component.oss';
179+
```
180+
181+
### `dagster-rules/no-apollo-client`
182+
183+
Enforces using Dagster's wrapped Apollo client with performance instrumentation.
184+
185+
**❌ Incorrect:**
186+
187+
```typescript
188+
import {useQuery} from '@apollo/client';
189+
```
190+
191+
**✅ Correct:**
192+
193+
```typescript
194+
import {useQuery} from '../apollo-client';
195+
// or
196+
import {useQuery} from '@dagster-io/ui-core/apollo-client';
197+
```
198+
199+
### `dagster-rules/no-react-router-route`
200+
201+
Enforces using Dagster's custom `Route` component instead of react-router-dom's.
202+
203+
**❌ Incorrect:**
204+
205+
```typescript
206+
import {Route} from 'react-router-dom';
207+
```
208+
209+
**✅ Correct:**
210+
211+
```typescript
212+
import {Route} from '../app/Route';
213+
// or
214+
import {Route} from '@dagster-io/ui-core/app/Route';
215+
```
216+
217+
### `dagster-rules/missing-shared-import`
218+
219+
Validates that imports using the `shared/` path reference files ending with `.oss`.
220+
221+
## Included Rules and Plugins
222+
223+
This config includes:
224+
225+
- **TypeScript** - `@typescript-eslint` recommended rules
226+
- **React** - React recommended rules + JSX runtime
227+
- **Jest** - Jest recommended rules
228+
- **Prettier** - Prettier integration with auto-formatting
229+
- **Import** - Import ordering and cycle detection
230+
- **React Hooks** - Rules of Hooks and exhaustive deps
231+
- **Unused Imports** - Auto-removal of unused imports
232+
- **Custom Dagster Rules** - Dagster-specific linting rules
233+
234+
## Rule Highlights
235+
236+
- **Import Ordering** - Automatically sorts imports by type and alphabetically
237+
- **No Default Exports** - Enforces named exports for better refactoring
238+
- **No Unused Imports** - Automatically removes unused imports
239+
- **Restricted Imports** - Prevents use of deprecated libraries (moment, lodash, etc.)
240+
- **React Best Practices** - Enforces modern React patterns
241+
- **TypeScript Strictness** - Disallows non-null assertions and other unsafe patterns
242+
243+
## Compatibility
244+
245+
- **ESLint**: ^9.0.0
246+
- **Node.js**: 18.18+, 20.9+, 21+
247+
- **TypeScript**: Any version (via typescript-eslint v8)
248+
249+
## Legacy Version (ESLint 8)
250+
251+
If you need ESLint 8 support, install version 1.x:
252+
253+
```bash
254+
yarn add -D @dagster-io/eslint-config@^1.0.0 eslint@^8.57.1
255+
```
256+
257+
Then use the legacy `.eslintrc.js` format:
258+
259+
```javascript
25260
// .eslintrc.js
26261
module.exports = {
27-
extends: ['some-other-config', '@dagster-io/eslint-config'],
262+
extends: ['@dagster-io/eslint-config'],
28263
};
29264
```
30265

31-
You can add other rules and settings to your `.eslintrc` as needed.
266+
## Contributing
267+
268+
This package is part of the Dagster monorepo. To make changes:
269+
270+
1. Update the config in `/js_modules/dagster-ui/packages/eslint-config`
271+
2. Test locally with `yarn lint` and `yarn test`
272+
3. Update version in `package.json`
273+
4. Update `CHANGELOG.md` with changes
274+
5. Submit a PR
275+
276+
## License
277+
278+
Apache-2.0

0 commit comments

Comments
 (0)