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

Migrate to eslint v9 #2486

Merged
merged 4 commits into from
Jan 23, 2025
Merged
Changes from all commits
Commits
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
50 changes: 0 additions & 50 deletions .eslintrc.js

This file was deleted.

39 changes: 39 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @ts-check

import eslint from '@eslint/js'
import tseslint from 'typescript-eslint'

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommended,
// Library
{
files: ['lib/**/*'],
rules: {
// Things we probably should fix at some point
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
// Things we won't allow
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-this-alias': [
'error',
{
allowDestructuring: true, // Allow `const { props, state } = this`; false by default
allowedNames: ['self'], // Allow `const self = this`; `[]` by default
},
],
},
},
// Tests
{
files: ['test/**/*'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/ban-ts-comment': 'warn',
},
}
)
1 change: 0 additions & 1 deletion lib/adapters/REST/endpoints/bulk-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { AxiosInstance } from 'contentful-sdk-core'
import type { GetBulkActionParams, GetSpaceEnvironmentParams } from '../../../common-types'
import type {
1 change: 0 additions & 1 deletion lib/adapters/REST/endpoints/release-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { AxiosInstance } from 'contentful-sdk-core'
import type { GetReleaseParams, GetSpaceEnvironmentParams } from '../../../common-types'
import type { ReleaseActionQueryOptions } from '../../../entities/release-action'
2 changes: 1 addition & 1 deletion lib/common-types.ts
Original file line number Diff line number Diff line change
@@ -2105,7 +2105,7 @@ export type MRReturn<
> = 'return' extends keyof MRActions[ET][Action] ? Promise<MRActions[ET][Action]['return']> : never

/** Base interface for all Payload interfaces. Used as part of the MakeRequestOptions to simplify payload definitions. */
// eslint-disable-next-line @typescript-eslint/no-empty-interface

export interface MakeRequestPayload {}

export interface MakeRequestOptions {
1,098 changes: 289 additions & 809 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
"docs:watch": "nodemon --exec npm run docs:dev -w lib typings",
"docs:publish": "npm run build:docs && ./node_modules/contentful-sdk-jsdoc/bin/publish-docs.sh contentful-management.js contentful-management",
"check-types": "tsc",
"lint": "eslint lib test --ext '.ts,.tsx,.js,.jsx'",
"lint": "eslint lib test",
"pretest": "rimraf coverage && npm run lint",
"test": "npm run test:cover-unit && npm run test:types && npm run test:cover-integration && npm run test:size",
"test:cover-unit": "npm run test:unit -- --coverage",
@@ -70,7 +70,6 @@
"devDependencies": {
"@babel/cli": "^7.24.6",
"@babel/core": "^7.24.6",
"@babel/eslint-parser": "^7.24.6",
"@babel/node": "^7.13.13",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
@@ -80,26 +79,20 @@
"@babel/preset-env": "^7.24.6",
"@babel/preset-typescript": "^7.24.7",
"@contentful/integration-test-utils": "^2.0.1",
"@eslint/js": "^9.15.0",
"@semantic-release/changelog": "^6.0.0",
"@size-limit/file": "^11.1.6",
"@types/json-patch": "0.0.30",
"@types/lodash": "^4.14.168",
"@types/node": "^20.12.13",
"@typescript-eslint/eslint-plugin": "^7.14.1",
"@typescript-eslint/parser": "^7.14.1",
"@vitest/browser": "^2.1.5",
"@vitest/coverage-v8": "^2.1.5",
"babel-loader": "^8.2.1",
"babel-plugin-inline-replace-variables": "^1.3.1",
"babel-plugin-lodash": "^3.3.4",
"contentful-sdk-jsdoc": "3.1.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.11.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.2.0",
"eslint": "^9.15.0",
"express": "^4.21.1",
"husky": "^9.1.7",
"in-publish": "^2.0.1",
@@ -116,7 +109,8 @@
"size-limit": "^11.1.6",
"type-fest": "^4.18.3",
"typedoc": "^0.26.2",
"typescript": "^5.5.2",
"typescript": "^5.6.3",
"typescript-eslint": "^8.16.0",
"vitest": "^2.1.5",
"webpack": "^5.91.0",
"webpack-bundle-analyzer": "^4.9.0",
4 changes: 2 additions & 2 deletions test/unit/mocks/http.ts
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ interface MockedHttp<T, R> extends Mock<[T], R> {
}

export default function setupHttpMock(promise = Promise.resolve({ data: {} })) {
const mock: MockedHttp<{}, typeof promise> = vi.fn().mockImplementation(() => {
const mock: MockedHttp<object, typeof promise> = vi.fn().mockImplementation(() => {
console.log('Mock: Returning promise via direct call')
return promise
})
@@ -48,5 +48,5 @@ export default function setupHttpMock(promise = Promise.resolve({ data: {} })) {

mock.cloneWithNewParams = () => mock

return mock as Required<MockedHttp<{}, typeof promise>>
return mock as Required<MockedHttp<object, typeof promise>>
}