Skip to content

Commit

Permalink
ESLint 9, flat config migration (#145)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Skoufis <askoufis@users.noreply.github.com>
  • Loading branch information
AaronMoat and askoufis authored Sep 23, 2024
1 parent 8327a31 commit 4067cde
Show file tree
Hide file tree
Showing 12 changed files with 2,732 additions and 2,485 deletions.
24 changes: 16 additions & 8 deletions .changeset/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const {
*/
const defaultChangelogFunctions = {
getDependencyReleaseLine: async (changesets, dependenciesUpdated) => {
if (dependenciesUpdated.length === 0) return '';
if (dependenciesUpdated.length === 0) {
return '';
}

const changesetLinks = changesets.map(
(changeset) => `- Updated dependencies [${changeset.commit}]`,
Expand Down Expand Up @@ -55,13 +57,15 @@ const gitHubChangelogFunctions = {
'Please provide a repo to this changelog generator like this:\n"changelog": ["./changelog.js", { "repo": "org/repo" }]',
);
}
if (dependenciesUpdated.length === 0) return '';
if (dependenciesUpdated.length === 0) {
return '';
}

const changesetLink = `- Updated dependencies [${(
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
let { links } = await getInfo({
const { links } = await getInfo({
repo: options.repo,
commit: cs.commit,
});
Expand Down Expand Up @@ -93,16 +97,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 @@ -113,6 +118,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 @@ -127,7 +133,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 @@ -152,6 +159,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
9 changes: 9 additions & 0 deletions .changeset/friendly-geckos-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'eslint-config-seek': major
---

Some [language options](https://eslint.org/docs/latest/use/configure/language-options) have been restored to defaults:

- `sourceType` is now set to the default of `module` (previously `script` in some scenarios).
- `ecmaVersion` is now set to the default of `latest` (previously `2022` and `6`)
- Babel has been removed
10 changes: 10 additions & 0 deletions .changeset/giant-eagles-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'eslint-config-seek': minor
---

Upgrade a number of dependencies. These should have no/minimal impact.

- `eslint-plugin-cypress`
- `eslint-config-prettier`
- `eslint-plugin-jest`
- `eslint-plugin-react`, `eslint-plugin-react-hooks`
9 changes: 9 additions & 0 deletions .changeset/orange-hats-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'eslint-config-seek': major
---

Replace `eslint-plugin-import` 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/`.

In addition, it's possible that this may introduce slight behaviour changes.
5 changes: 5 additions & 0 deletions .changeset/quick-trainers-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-config-seek': major
---

Require TypeScript peer dependency >=5.5.4
14 changes: 14 additions & 0 deletions .changeset/small-jeans-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'eslint-config-seek': major
---

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

These changes may affect your project setup if you are 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 to autofix and/or adjust your code after running ESLint.

As part of this migration, this project has migrated to Flat ESLint configuration. Read the migration guide: https://eslint.org/docs/latest/use/configure/migration-guide.
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* @seek-oss/sku-maintainers
* @seek-oss/front-end-contributors
* @seek-oss/sku-maintainers @seek-oss/sig-backend-tooling
28 changes: 12 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@

This package includes the shareable ESLint configuration used by [SEEK](https://github.com/seek-oss/).

## Usage in sku Projects
## Usage in sku and skuba Projects

The easiest way to use this configuration is with [sku](https://github.com/seek-oss/sku), which includes it by default.
The easiest way to use this configuration is with [sku](https://github.com/seek-oss/sku) or [skuba](https://github.com/seek-oss/skuba).

**You don’t need to install it separately in sku projects.**
**You don’t need to install it separately in sku and skuba projects.**

## Usage Outside of sku
## Usage Outside of sku and skuba

If you want to use this ESLint configuration in a project not built with sku, you can install it with following steps.
If you want to use this ESLint configuration in a project not built with sku or skuba, you can install it with following steps.

First, install this package, ESLint and the necessary plugins listed in this project's [package.json](package.json).
First, install this package, and the necessary peer dependencies listed in this project's [package.json](package.json).

Then create a file named `.eslintrc` with following contents in the root folder of your project:
Then create a file named `eslint.config.js` with the following contents in the root folder of your project:

```json
{
"extends": "seek"
}
```js
module.exports = require('eslint-config-seek');
```

The default configuration includes support for React projects. For projects that are not based on React, the "base" configuration should be used instead:

```json
{
"extends": "seek/base"
}
```js
module.exports = require('eslint-config-seek/base');
```

You can override the settings from `eslint-config-seek` by editing the `.eslintrc` file. Learn more about [configuring ESLint](http://eslint.org/docs/user-guide/configuring) on the ESLint website.
You can override the settings from `eslint-config-seek` by editing the `eslint.config.js` file. Learn more about [configuring ESLint](https://eslint.org/docs/latest/use/configure/) on the ESLint website.

## License

Expand Down
Loading

0 comments on commit 4067cde

Please sign in to comment.