Skip to content

Commit 26fc571

Browse files
author
naseemkullah
committed
feat: add no-floating-promises lint rule
Only warn in tests, disable rule for existing occurences in non-test modules. Signed-off-by: naseemkullah <[email protected]>
1 parent 853fcb9 commit 26fc571

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

eslint.config.js

+13-11
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,28 @@ module.exports = {
44
"header"
55
],
66
extends: [
7-
"./node_modules/gts",
7+
"./node_modules/gts",
88
],
99
parser: "@typescript-eslint/parser",
1010
parserOptions: {
11-
"project": "./tsconfig.json"
11+
"project": "./tsconfig.json"
1212
},
1313
rules: {
14+
"@typescript-eslint/no-floating-promises": 2,
1415
"@typescript-eslint/no-this-alias": "off",
1516
"eqeqeq": [
1617
"error",
1718
"smart"
1819
],
1920
"prefer-rest-params": "off",
2021
"@typescript-eslint/naming-convention": [
21-
"error",
22-
{
23-
"selector": "memberLike",
24-
"modifiers": ["private", "protected"],
25-
"format": ["camelCase"],
26-
"leadingUnderscore": "require"
27-
}
22+
"error",
23+
{
24+
"selector": "memberLike",
25+
"modifiers": ["private", "protected"],
26+
"format": ["camelCase"],
27+
"leadingUnderscore": "require"
28+
}
2829
],
2930
"no-console": "error",
3031
"no-shadow": "off",
@@ -35,8 +36,8 @@ module.exports = {
3536
"prettier/prettier": ["error", { "singleQuote": true, "arrowParens": "avoid" }],
3637
"node/no-deprecated-api": ["warn"],
3738
"header/header": [2, "block", [{
38-
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
39-
template:
39+
pattern: / \* Copyright The OpenTelemetry Authors[\r\n]+ \*[\r\n]+ \* Licensed under the Apache License, Version 2\.0 \(the \"License\"\);[\r\n]+ \* you may not use this file except in compliance with the License\.[\r\n]+ \* You may obtain a copy of the License at[\r\n]+ \*[\r\n]+ \* https:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0[\r\n]+ \*[\r\n]+ \* Unless required by applicable law or agreed to in writing, software[\r\n]+ \* distributed under the License is distributed on an \"AS IS\" BASIS,[\r\n]+ \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.[\r\n]+ \* See the License for the specific language governing permissions and[\r\n]+ \* limitations under the License\./gm,
40+
template:
4041
`\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n `
4142
}]]
4243
},
@@ -48,6 +49,7 @@ module.exports = {
4849
"@typescript-eslint/ban-ts-ignore": "off",
4950
"@typescript-eslint/no-empty-function": "off",
5051
"@typescript-eslint/no-explicit-any": "off",
52+
"@typescript-eslint/no-floating-promises": 1,
5153
"@typescript-eslint/no-unused-vars": "off",
5254
"@typescript-eslint/no-var-requires": "off",
5355
"@typescript-eslint/no-shadow": ["off"],

packages/opentelemetry-exporter-collector-grpc/src/util.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function onInit<ExportItem, ServiceRequest>(
3838

3939
const includeDirs = [path.resolve(__dirname, '..', 'protos')];
4040

41+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
4142
protoLoader
4243
.load(collector.getServiceProtoPath(), {
4344
keepCase: false,

packages/opentelemetry-metrics/src/export/Controller.ts

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class PushController extends Controller {
3737
) {
3838
super();
3939
this._timer = setInterval(() => {
40+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
4041
this._collect();
4142
}, interval);
4243
unrefTimer(this._timer);

0 commit comments

Comments
 (0)