Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint 9, flat config migration #1537

Merged
merged 50 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3fcccf7
deps: eslint ^9.0.0
renovate[bot] Jul 31, 2024
b7b207b
very wip
AaronMoat Jul 31, 2024
5574380
wip
AaronMoat Aug 4, 2024
904e3d4
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Aug 4, 2024
11cb9d0
wip2
AaronMoat Aug 4, 2024
60820e3
oh god
AaronMoat Aug 4, 2024
386acdb
More stuff works
AaronMoat Aug 4, 2024
fd49823
wheeee
AaronMoat Aug 4, 2024
9ad25ba
wheeee was ambitious
AaronMoat Aug 4, 2024
2e647f7
Debugging
AaronMoat Aug 9, 2024
e134dee
Further debugging
AaronMoat Aug 9, 2024
c3b0c41
Revert "Further debugging"
AaronMoat Aug 9, 2024
180e146
Revert "Debugging"
AaronMoat Aug 9, 2024
839fa60
🧐
AaronMoat Aug 10, 2024
fdf1990
Merge branch 'main' into renovate-eslint-9.x
AaronMoat Aug 10, 2024
c210283
Add some changesets
AaronMoat Aug 10, 2024
1084b80
whoops
AaronMoat Aug 10, 2024
725fb5b
Testing from one of SEEK's internal repos
AaronMoat Aug 11, 2024
f248e0e
Fix test
AaronMoat Aug 11, 2024
1b3a7f4
Write some tests
AaronMoat Aug 11, 2024
6e0f426
make skuba happy
AaronMoat Aug 11, 2024
8614678
Write some tests part 2
AaronMoat Aug 11, 2024
fc9ebde
Run `skuba format`
seek-oss-ci Aug 11, 2024
ea5ad37
Hmm, is VScode buggy with ESLint 9?
AaronMoat Aug 11, 2024
55d34c7
Bump eslint-config-seek
AaronMoat Aug 19, 2024
876dedf
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Sep 6, 2024
d22b4d5
Run `skuba format`
seek-oss-ci Sep 6, 2024
bd41c73
Bump ESLint
AaronMoat Sep 8, 2024
2e19dad
Bump again
AaronMoat Sep 8, 2024
782f35e
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Sep 9, 2024
6523acd
Update .changeset/thick-taxis-vanish.md
AaronMoat Sep 9, 2024
73e0648
Try to please Sam
AaronMoat Sep 9, 2024
7b70b23
Be less silly
AaronMoat Sep 10, 2024
b15ed61
Be more efficient
AaronMoat Sep 10, 2024
a3a50d4
Fewer magic strings
AaronMoat Sep 10, 2024
69d72d0
Restore comments
AaronMoat Sep 10, 2024
1a50617
Clean code takes another victim
AaronMoat Sep 10, 2024
ddf744d
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Sep 10, 2024
a8a4e78
Update eslint-config-seek
AaronMoat Sep 18, 2024
c9ed5cb
oops
AaronMoat Sep 18, 2024
e331527
Update eslint-config-seek
AaronMoat Sep 22, 2024
38119b1
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Sep 22, 2024
ec05541
Merge branch 'main' into renovate-eslint-9.x
AaronMoat Sep 22, 2024
e0c7435
Update eslint-config-seek, and add @eslint/core as a temporary(?) wor…
AaronMoat Sep 23, 2024
bcd7fd8
Merge remote-tracking branch 'origin/main' into renovate-eslint-9.x
AaronMoat Sep 23, 2024
11c8008
Yay
AaronMoat Sep 23, 2024
1246869
Merge branch 'main' into renovate-eslint-9.x
AaronMoat Sep 23, 2024
b162fc4
Update src/cli/lint/internalLints/upgrade/patches/8.2.1/upgradeESLint.ts
AaronMoat Sep 24, 2024
b5b1b91
Simplify
AaronMoat Sep 24, 2024
57c67df
Run `skuba format`
seek-oss-ci Sep 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/big-weeks-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'skuba': major
---

lint: Migrate to ESLint 9 and `@typescript-eslint` 8.

These changes may affect your project setup if customising your ESLint configuration. See the individual migration guides:

- https://eslint.org/docs/latest/use/migrate-to-9.0.0
- https://typescript-eslint.io/blog/announcing-typescript-eslint-v8

In addition, through these major upgrades, some lint rules have changed or have been renamed. You will likely need adjust your code after running ESLint.

Furthermore, `eslint-plugin-import` has been replaced with `eslint-plugin-import-x`. To migrate, any references to `eslint-plugin-import` should be replaced with `eslint-plugin-import-x`, and `import/` rules with `import-x/`.

As part of this migration, skuba has migrated to using Flat ESLint configuration. Read the migration: https://eslint.org/docs/latest/use/configure/migration-guide.

`skuba format` will attempt to migrate to flat configuration for you, where `.eslintignore` and `.eslintrc` are replaced by `eslint.config.js`.
14 changes: 9 additions & 5 deletions .changeset/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,17 @@ const gitHubChangelogFunctions = {

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
let num = Number(pr);
if (!isNaN(num)) prFromSummary = num;
const num = Number(pr);
if (!isNaN(num)) {
prFromSummary = num;
}
return '';
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
commitFromSummary = commit;
return '';
})
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, (_, user) => {
usersFromSummary.push(user);
.replace(/^\s*(?:author|user):\s*@?([^\s]+)/gim, () => {
return '';
})
.trim();
Expand All @@ -87,6 +88,7 @@ const gitHubChangelogFunctions = {

const links = await (async () => {
if (prFromSummary !== undefined) {
// eslint-disable-next-line no-shadow
let { links } = await getInfoFromPullRequest({
repo: options.repo,
pull: prFromSummary,
Expand All @@ -101,7 +103,8 @@ const gitHubChangelogFunctions = {
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
let { links } = await getInfo({
// eslint-disable-next-line no-shadow
const { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom,
});
Expand All @@ -128,6 +131,7 @@ const gitHubChangelogFunctions = {
if (process.env.GITHUB_TOKEN) {
module.exports = gitHubChangelogFunctions;
} else {
// eslint-disable-next-line no-console
console.warn(
`Defaulting to Git-based versioning.
Enable GitHub-based versioning by setting the GITHUB_TOKEN environment variable.
Expand Down
1 change: 1 addition & 0 deletions .changeset/inject.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Hack to add a preamble from .changeset/.PREAMBLE.md to the CHANGELOG.md for a given release
/* eslint-disable no-sync */

const fs = require('fs');

Expand Down
20 changes: 20 additions & 0 deletions .changeset/rich-chairs-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'skuba': minor
---

lint: Replace `.buildkite/` files with duplicated YAML merge keys, for example:

```yaml
# Before
- <<: *deploy
<<: *docker
label: stuff

# After
- <<: [*deploy, *docker]
label: stuff
```

This should have no functional change, and is to support standardised YAML parsing across different tools, including the latest ESLint upgrades.

This migration will not be capture all cases of this (e.g. if there are keys between the merge keys). If you have other cases, update them following the example above.
16 changes: 16 additions & 0 deletions .changeset/thick-taxis-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'eslint-config-skuba': major
---

Migrate to ESLint 9, `@typescript-eslint` 8, `eslint-config-seek` 14.

These changes may affect your project setup if customising your ESLint configuration. See the individual migration guides:

- https://eslint.org/docs/latest/use/migrate-to-9.0.0
- https://typescript-eslint.io/blog/announcing-typescript-eslint-v8

Through these major upgrades, some lint rules have changed or have been renamed. You will likely need to adjust your code after running ESLint.

As part of this migration, this project has migrated to Flat ESLint configuration. Read the migration: https://eslint.org/docs/latest/use/configure/migration-guide.

Furthermore, `eslint-plugin-import` has been replaced with `eslint-plugin-import-x`. To migrate, any references to `eslint-plugin-import` should be replaced with `eslint-plugin-import-x`, and `import/` rules with `import-x/`.
20 changes: 0 additions & 20 deletions .eslintignore

This file was deleted.

37 changes: 0 additions & 37 deletions .eslintrc.js

This file was deleted.

4 changes: 1 addition & 3 deletions config/eslint.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
extends: ['skuba'],
};
module.exports = require('eslint-config-skuba');
3 changes: 1 addition & 2 deletions docs/cli/init.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,12 @@ Familiarise yourself with the directory structure that **skuba** has created:
├── app.test.ts
├── app.ts
├── .dockerignore
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .nvmrc
├── .prettierignore
├── .prettierrc.js
├── Dockerfile
├── eslint.config.js
├── README.md
├── docker-compose.yml
├── jest.config.js
Expand Down
15 changes: 8 additions & 7 deletions docs/deep-dives/eslint.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ Please contribute to the [eslint-config-seek] preset if you feel something is mi
It may worthwhile starting with a discussion in [#typescriptification] to garner feedback.

If you wish to enforce additional rules within a given codebase or team,
you can [extend] your `.eslintrc.js`:
you can [extend] your `eslint.config.js`:

```javascript
module.exports = {
extends: ['skuba'],
rules: {
// https://eslint.org/docs/rules/complexity
complexity: ['error', { max: 3 }],
module.exports = [
...require('eslint-config-skuba'),
{
rules: {
// Your custom rules here
},
},
};
];
```

Let's check that our new rule has taken effect.
Expand Down
56 changes: 56 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const tsParser = require('@typescript-eslint/parser');

const skuba = require('eslint-config-skuba');

module.exports = [
{
ignores: [
'integration/base/',
'integration/format/',
'template/',
'packages/**/*/lib*/',
],
},
...skuba,
{
rules: {
'no-process-exit': 'off',
},
},
{
files: ['integration/**/*.{ts,cts,mts,tsx}'],

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
allowAutomaticSingleRunInference: false,
},
},
},
{
files: ['src/**/*.{ts,cts,mts,tsx}'],

rules: {
'no-restricted-imports': [
'error',
{
paths: [
{
name: 'fs',
message:
'Prefer fs-extra as it implements graceful-fs behaviour.',
},
{
name: 'fs/promises',
message:
'Prefer fs-extra as it implements graceful-fs behaviour.',
},
],
},
],
},
},
];
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
},
"dependencies": {
"@esbuild-plugins/tsconfig-paths": "^0.1.0",
"@eslint/migrate-config": "^1.2.0",
"@jest/types": "^29.0.0",
"@octokit/graphql": "^8.0.0",
"@octokit/graphql-schema": "^15.3.0",
Expand All @@ -83,7 +84,7 @@
"ejs": "^3.1.6",
"enquirer": "^2.3.6",
"esbuild": "~0.24.0",
"eslint": "^8.56.0",
"eslint": "^9.11.1",
"eslint-config-skuba": "workspace:*",
"execa": "^5.0.0",
"fast-glob": "^3.3.2",
Expand Down
15 changes: 0 additions & 15 deletions packages/eslint-config-skuba/.eslintignore

This file was deleted.

1 change: 1 addition & 0 deletions packages/eslint-config-skuba/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('.');
Loading