Skip to content

Commit

Permalink
chore: Updates eslint config
Browse files Browse the repository at this point in the history
* Adds back in support for react-hooks, prettier and testing-library
  eslint support

* Unfortunately, react plugin is still generating v9 incompatible errors
  • Loading branch information
phantomjinx committed Oct 8, 2024
1 parent 3f14d16 commit 44cd63c
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 64 deletions.
1 change: 0 additions & 1 deletion docker/gateway/src/gateway-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ function appPost(uri: string, body: Record<string, unknown> | Record<string, unk
describe.each([
{ title: 'proxyJolokiaAgentWithoutRbac', rbac: false },
{ title: 'proxyJolokiaAgentWithRbac', rbac: true },
// eslint-disable-next-line
])('$title', ({ title, rbac }) => {
const testAuth = rbac ? 'RBAC Enabled' : 'RBAC Disabled'

Expand Down
4 changes: 2 additions & 2 deletions docker/gateway/src/gateway-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ gatewayServer.use(
changeOrigin: false,
ws: true,
secure: false,
// eslint-disable-next-line

pathFilter: (path, _) => {
const result = proxyMasterGuard('/master' + path)
return result.status
},
// eslint-disable-next-line

pathRewrite: (path, _) => {
return path.replace('/master', '')
},
Expand Down
1 change: 0 additions & 1 deletion docker/gateway/src/jolokia-agent/jolokia-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ function appPost(uri: string, body: Record<string, unknown> | Record<string, unk
describe.each([
{ title: 'proxyJolokiaAgentWithoutRbac', rbac: false },
{ title: 'proxyJolokiaAgentWithRbac', rbac: true },
// eslint-disable-next-line
])('$title', ({ title, rbac }) => {
const testAuth = rbac ? 'RBAC Enabled' : 'RBAC Disabled'

Expand Down
128 changes: 88 additions & 40 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,70 +1,118 @@
import jsPlugin from '@eslint/js'
import tsPlugin from 'typescript-eslint'
import importPlugin from 'eslint-plugin-import'
import reactHooksPlugin from "eslint-plugin-react-hooks"
import react from 'eslint-plugin-react'
import configPrettier from 'eslint-config-prettier'

// "prettier",
// Plugins still requiring compat library as not yet fully v9 flat-config compliant
import { fixupPluginRules } from '@eslint/compat'
import reactHooks from 'eslint-plugin-react-hooks'
import testingLibrary from 'eslint-plugin-testing-library'

export default [
{
ignores: [
"*.js",
"*.cjs",
"*.mjs",
"**/.jestEnvVars.js",
".gitignore",
".dockerignore",
"**/.env.*",
"**/env.*",
"**/ignore/**/*",
"**/__mocks__/*.js",
"**/testdata/**/*.js",
"**/jest.config.ts",
"**/tsup.config*.ts",
"**/webpack*.js",
"**/proxy-dev-server.js",
"**/dist/*",
"**/build/*",
'*.js',
'*.cjs',
'*.mjs',
'**/.jestEnvVars.js',
'.gitignore',
'.dockerignore',
'**/.env.*',
'**/env.*',
'**/ignore/**/*',
'**/__mocks__/*.js',
'**/testdata/**/*.js',
'**/jest.config.ts',
'**/tsup.config*.ts',
'**/webpack*.js',
'**/proxy-dev-server.js',
'**/dist/*',
'**/build/*',
],
},

configPrettier,
jsPlugin.configs.recommended,
...tsPlugin.configs.recommended,
importPlugin.flatConfigs.recommended,

{
plugins: {
"react-hooks": reactHooksPlugin,
// Re-enable when react plugin is working correctly with eslint v9
// react,
'react-hooks': fixupPluginRules({
rules: reactHooks.rules,
}),
'testing-library': fixupPluginRules({
rules: testingLibrary.rules,
}),
},

languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
}
},

rules: {
semi: ["error", "never"],
...testingLibrary.configs['flat/react'].rules,
...reactHooks.configs.recommended.rules,

// Re-enable when react plugin is working correctly with eslint v9
// 'react/jsx-uses-react': 'error',
// 'react/jsx-uses-vars': 'error',

"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"],
semi: ['error', 'never'],

'no-undef': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'none',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],

"@typescript-eslint/explicit-member-accessibility": [
"warn", {
accessibility: "no-public",
}
'@typescript-eslint/explicit-member-accessibility': [
'warn',
{
accessibility: 'no-public',
},
],

"@typescript-eslint/no-empty-function": [
"error", {
allow: ["constructors"],
}
'@typescript-eslint/no-empty-function': [
'error',
{
allow: ['constructors'],
},
],

"@typescript-eslint/no-redeclare": "off",
'@typescript-eslint/no-redeclare': 'off',

"import/no-default-export": "error",
"import/no-unresolved": "off",
"import/named": "off",
"import/first": "error",
'import/no-default-export': 'error',
'import/no-unresolved': 'off',
'import/named': 'off',
'import/first': 'error',

"react/prop-types": "off",
'react/prop-types': 'off',

"no-console": "error",
}
}
'no-template-curly-in-string': 'error',
'no-console': 'error',

'testing-library/await-async-queries': 'off',
'testing-library/no-debugging-utils': [
'warn',
{
utilsToCheckFor: {
debug: false,
},
},
],
},
},
]
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@
"kustomize:image": "cd deploy/base && kustomize edit set image hawtio/online=quay.io/${ORG:-hawtio}/${PROJECT:-online}:${TAG:-latest}"
},
"devDependencies": {
"@eslint/compat": "^1.2.0",
"@eslint/js": "^9.12.0",
"compression-webpack-plugin": "^11.1.0",
"concurrently": "^8.2.2",
"cz-conventional-changelog": "3.3.0",
"eslint": "^9.1.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react-hooks": "^4.6.2",
"prettier": "3.3.3"
"eslint-plugin-testing-library": "^6.3.0",
"prettier": "3.3.3",
"typescript-eslint": "^8.8.0"
},
"config": {
"commitizen": {
Expand All @@ -75,9 +79,5 @@
},
"resolutions": {
"eslint-config-react-app/eslint-plugin-react-hooks": "^4.6.2"
},
"dependencies": {
"eslint-plugin-import": "^2.31.0",
"typescript-eslint": "^8.8.0"
}
}
1 change: 0 additions & 1 deletion packages/kubernetes-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@testing-library/jest-dom": "^6.5.0",
"@types/jest": "^29.5.12",
"babel-jest": "^29.6.1",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jest-extended": "^4.0.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/kubernetes-api/src/client/namespace-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class MockCollectionImpl {
return watchCb
}

// eslint-disable-next-line
unwatch(cb: ProcessDataCallback<KubeObject>) {
// no-op
}
Expand Down Expand Up @@ -89,7 +88,6 @@ describe('namespace-client', () => {
})

test('getNamespace', () => {
// eslint-disable-next-line
const cb = (_: KubePod[], __: number) => {
// Nothing to do
}
Expand All @@ -99,7 +97,6 @@ describe('namespace-client', () => {
})

test('not-connected-emptyJolokiaPods', () => {
// eslint-disable-next-line
const cb = (_: KubePod[], __: number) => {
// Nothing to do
}
Expand Down Expand Up @@ -282,7 +279,7 @@ describe('namespace-client', () => {
let firstCallbackComplete = false

// Callback used for the namespace client - use done() to restrict the test
// eslint-disable-next-line

const cb = (jolokiaPods: KubePod[], fullPodCount: number) => {
if (!firstCallbackComplete) {
/*
Expand Down
2 changes: 1 addition & 1 deletion packages/kubernetes-api/src/client/namespace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class NamespaceClient implements Paging {
* Remove watchers for pods not in the slice of the filtered/sorted list
*/
Object.entries(this._podWatchers)
.filter(([name, _]) => !pagedPods.includes(name)) // eslint-disable-line
.filter(([name, _]) => !pagedPods.includes(name))
.forEach(([name, podWatcher]) => {
log.debug(`[NamespaceClient ${this._namespace}]: deleting pod watcher [${name}]`)

Expand Down
4 changes: 2 additions & 2 deletions packages/kubernetes-api/src/client/object-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ export class ObjectListImpl<T extends KubeObject> extends EventEmitter implement
this.on(WatchActions.ANY, objects => {
log.debug(this.kind, 'changed:', objects)
})
// eslint-disable-next-line

this.on(WatchActions.INIT, objects => {
log.debug(this.kind, 'initialized')
})
}
// eslint-disable-next-line

this.on(WatchActions.ANY, objects => {
this.initialize()
})
Expand Down
1 change: 0 additions & 1 deletion packages/kubernetes-api/src/client/ws-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export class WSHandlerImpl<T extends KubeObject> implements WSHandler<T> {
if (this.socket) this.socket.send(data)
}

// eslint-disable-next-line
shouldClose(event: Event): boolean {
if (this.destroyed && this.socket && this.socket.readyState === WebSocket.OPEN) {
log.debug(
Expand Down
1 change: 0 additions & 1 deletion packages/management-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"@types/jquery": "^3.5.30",
"@types/jsonpath": "^0.2.4",
"babel-jest": "^29.6.1",
"eslint-config-react-app": "^7.0.1",
"jest": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jest-extended": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/oauth/src/form/form-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class FormService implements OAuthProtoService {
}

log.debug('Set authorization header to Openshift auth token for AJAX requests')
// eslint-disable-next-line

const beforeSend = (xhr: JQueryXHR, settings: JQueryAjaxSettings) => {
// Set bearer token is used
xhr.setRequestHeader('Authorization', `Bearer ${this.userProfile.getToken()}`)
Expand Down
1 change: 0 additions & 1 deletion packages/oauth/src/form/login/form-auth-login-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class FormAuthLoginService {
fetchPath<void>(
joinPaths(masterUri, 'api'),
{
// eslint-disable-next-line
success: async (_: string) => {
log.debug('Connected to master uri api')
callback.success()
Expand Down
2 changes: 1 addition & 1 deletion packages/online-shell/src/discover/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type DiscoverContext = {

export const DiscoverContext = createContext<DiscoverContext>({
refreshing: false,
// eslint-disable-next-line

setRefreshing: (refresh: boolean) => {
// no-op
},
Expand Down
27 changes: 25 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,18 @@ __metadata:
languageName: node
linkType: hard

"@eslint/compat@npm:^1.2.0":
version: 1.2.0
resolution: "@eslint/compat@npm:1.2.0"
peerDependencies:
eslint: ^9.10.0
peerDependenciesMeta:
eslint:
optional: true
checksum: 10/4896c417c1f197a6e9cc12592a661f0d91d73bdbb936785555c5bb81d2359a59fe90aac2422e7ce525e9dd5bb13227cbfec1263f9263591ccca200e9038057bf
languageName: node
linkType: hard

"@eslint/config-array@npm:^0.18.0":
version: 0.18.0
resolution: "@eslint/config-array@npm:0.18.0"
Expand Down Expand Up @@ -2107,7 +2119,6 @@ __metadata:
"@types/jsonpath": "npm:^0.2.4"
"@types/node": "npm:^20.14.9"
babel-jest: "npm:^29.6.1"
eslint-config-react-app: "npm:^7.0.1"
eventemitter3: "npm:^5.0.1"
jest: "npm:^29.6.1"
jest-environment-jsdom: "npm:^29.6.1"
Expand Down Expand Up @@ -2176,7 +2187,6 @@ __metadata:
"@types/jquery": "npm:^3.5.30"
"@types/jsonpath": "npm:^0.2.4"
babel-jest: "npm:^29.6.1"
eslint-config-react-app: "npm:^7.0.1"
eventemitter3: "npm:^5.0.1"
jest: "npm:^29.6.1"
jest-environment-jsdom: "npm:^29.6.1"
Expand Down Expand Up @@ -2271,6 +2281,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@hawtio/online-root@workspace:."
dependencies:
"@eslint/compat": "npm:^1.2.0"
"@eslint/js": "npm:^9.12.0"
compression-webpack-plugin: "npm:^11.1.0"
concurrently: "npm:^8.2.2"
Expand All @@ -2280,6 +2291,7 @@ __metadata:
eslint-config-react-app: "npm:^7.0.1"
eslint-plugin-import: "npm:^2.31.0"
eslint-plugin-react-hooks: "npm:^4.6.2"
eslint-plugin-testing-library: "npm:^6.3.0"
prettier: "npm:3.3.3"
typescript-eslint: "npm:^8.8.0"
languageName: unknown
Expand Down Expand Up @@ -8059,6 +8071,17 @@ __metadata:
languageName: node
linkType: hard

"eslint-plugin-testing-library@npm:^6.3.0":
version: 6.3.0
resolution: "eslint-plugin-testing-library@npm:6.3.0"
dependencies:
"@typescript-eslint/utils": "npm:^5.58.0"
peerDependencies:
eslint: ^7.5.0 || ^8.0.0
checksum: 10/192b112f84f90cc7eee28965b3e7792e8d4cda71aa29690d8180f1ae9cd0e8d6a8851ee992d37285a76750f8638c04e76f768e1885168f060ca169b72ac9ec6c
languageName: node
linkType: hard

"eslint-scope@npm:5.1.1, eslint-scope@npm:^5.1.1":
version: 5.1.1
resolution: "eslint-scope@npm:5.1.1"
Expand Down

0 comments on commit 44cd63c

Please sign in to comment.