Skip to content

ESLint 9, flat config migration #145

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

Merged
merged 25 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
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
5 changes: 5 additions & 0 deletions .changeset/friendly-geckos-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-config-seek': minor
---

Babel now treats all Javascript files to have a [`sourceType`](https://babeljs.io/docs/options#sourcetype) of `module` (previously `script`).
11 changes: 11 additions & 0 deletions .changeset/giant-eagles-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'eslint-config-seek': minor
---

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

- `@babel/core`, `@babel/eslint-parser`, `@babel/preset-react`
- `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
15 changes: 15 additions & 0 deletions .changeset/small-jeans-wave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
'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
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
Loading