build(websocket): upgrade ESLint to v9 (#30359)

Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
Đỗ Trọng Hải 2024-09-23 01:14:42 +07:00 committed by GitHub
parent f3e4347a8b
commit 55d9d57112
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 794 additions and 845 deletions

View File

@ -1,20 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
*.min.js
node_modules
dist
coverage

View File

@ -1,40 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
env: {
node: true,
browser: true,
},
plugins: [
'@typescript-eslint',
'lodash',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
rules: {
"lodash/import-scope": [2, "member"],
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-var-requires": 0,
},
};

View File

@ -0,0 +1,53 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
const typescriptEslintParser = require('@typescript-eslint/parser');
const typescriptEslintPlugin = require('@typescript-eslint/eslint-plugin');
const typescriptEslint = require('typescript-eslint');
const lodashEslintPlugin = require('eslint-plugin-lodash');
const eslintConfigPrettier = require('eslint-config-prettier');
const js = require('@eslint/js');
const globals = require('globals');
module.exports = [
js.configs.recommended,
...typescriptEslint.configs.recommended,
eslintConfigPrettier,
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
ignores: ['*.min.js', 'node_modules', 'dist', 'coverage'],
languageOptions: {
parser: typescriptEslintParser,
globals: {
...globals.browser,
...globals.node,
},
},
plugins: {
typescript: typescriptEslintPlugin,
lodash: lodashEslintPlugin,
},
rules: {
'lodash/import-scope': [2, 'member'],
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-require-imports': 0, // Re-enable once superset-websocket is converted to ESM
},
},
];

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
"start": "node dist/index.js start", "start": "node dist/index.js start",
"test": "NODE_ENV=test jest -i spec", "test": "NODE_ENV=test jest -i spec",
"type": "tsc --noEmit", "type": "tsc --noEmit",
"eslint": "eslint --ext .js,.jsx,.ts,.tsx", "eslint": "eslint",
"lint": "npm run eslint -- . && npm run type", "lint": "npm run eslint -- . && npm run type",
"dev-server": "ts-node src/index.ts start", "dev-server": "ts-node src/index.ts start",
"build": "tsc", "build": "tsc",
@ -17,7 +17,6 @@
}, },
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@types/lodash": "^4.17.7",
"cookie": "^0.6.0", "cookie": "^0.6.0",
"hot-shots": "^10.0.0", "hot-shots": "^10.0.0",
"ioredis": "^4.28.0", "ioredis": "^4.28.0",
@ -28,24 +27,28 @@
"ws": "^8.18.0" "ws": "^8.18.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.11.0",
"@types/cookie": "^0.6.0", "@types/cookie": "^0.6.0",
"@types/eslint__js": "^8.42.3",
"@types/ioredis": "^4.27.8", "@types/ioredis": "^4.27.8",
"@types/lodash": "^4.17.7",
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/jsonwebtoken": "^9.0.6", "@types/jsonwebtoken": "^9.0.6",
"@types/lodash": "^4.17.7",
"@types/node": "^22.0.2", "@types/node": "^22.0.2",
"@types/uuid": "^10.0.0", "@types/uuid": "^10.0.0",
"@types/ws": "^8.5.12", "@types/ws": "^8.5.12",
"@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^5.62.0", "@typescript-eslint/parser": "^8.6.0",
"eslint": "^8.57.0", "eslint": "^9.11.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-lodash": "^7.4.0", "eslint-plugin-lodash": "^8.0.0",
"globals": "^15.9.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"prettier": "^3.3.3", "prettier": "^3.3.3",
"ts-jest": "^29.2.5", "ts-jest": "^29.2.5",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
"typescript": "^5.5.4" "typescript": "^5.5.4",
"typescript-eslint": "^8.6.0"
}, },
"engines": { "engines": {
"node": "^16.9.1", "node": "^16.9.1",

View File

@ -89,7 +89,10 @@ describe('server', () => {
end: endMock, end: endMock,
}; };
server.httpRequest(request as any, response as any); server.httpRequest(
request as unknown as http.IncomingMessage,
response as unknown as http.ServerResponse<http.IncomingMessage>,
);
expect(writeHeadMock).toBeCalledTimes(1); expect(writeHeadMock).toBeCalledTimes(1);
expect(writeHeadMock).toHaveBeenLastCalledWith(200); expect(writeHeadMock).toHaveBeenLastCalledWith(200);
@ -115,7 +118,10 @@ describe('server', () => {
end: endMock, end: endMock,
}; };
server.httpRequest(request as any, response as any); server.httpRequest(
request as unknown as http.IncomingMessage,
response as unknown as http.ServerResponse<http.IncomingMessage>,
);
expect(writeHeadMock).toBeCalledTimes(1); expect(writeHeadMock).toBeCalledTimes(1);
expect(writeHeadMock).toHaveBeenLastCalledWith(404); expect(writeHeadMock).toHaveBeenLastCalledWith(404);

View File

@ -90,7 +90,7 @@ function configFromFile(): Partial<ConfigType> {
const configFile = isTest ? '../config.test.json' : '../config.json'; const configFile = isTest ? '../config.test.json' : '../config.json';
try { try {
return require(configFile); return require(configFile);
} catch (err) { } catch {
console.warn('config.json file not found'); console.warn('config.json file not found');
return {}; return {};
} }

View File

@ -36,6 +36,7 @@ export type StreamResult = [
// sync with superset-frontend/src/components/ErrorMessage/types // sync with superset-frontend/src/components/ErrorMessage/types
export type ErrorLevel = 'info' | 'warning' | 'error'; export type ErrorLevel = 'info' | 'warning' | 'error';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type SupersetError<ExtraType = Record<string, any> | null> = { export type SupersetError<ExtraType = Record<string, any> | null> = {
error_type: string; error_type: string;
extra: ExtraType; extra: ExtraType;