Skip to content

Commit 736f280

Browse files
authored
fixing source filename to follow kebab-case convention and other eslint issues #1423 (#1424)
* chore: upgrade to eslint 9 #1426 * chore(cli): fix filename to follow convention #1423 * chore(core): fix filename to follow convention #1423 * chore(eslint): enforce filenaming convention check #1423 * chore(eslint): activate @typescript-eslint/no-floating-promises rule as warning * chore(binding-opcua): fix floating promise issues * chore(binding-http): remove console.log from tests (eslint) * chore(binding-mbus): remove console.log from tests (eslint) * chore(binding-http): remove console.log from tests (eslint) * chore(binding-modbus): remove console.log from tests (eslint) * chore(cli): fix eslint console.log issue * chore(examples): fix eslint console.log issue * chore(core): remove console.log from tests (eslint) * chore(eslint): enfore no-console rule * chore(eslint): switch to check-file instead of react-nameing-convention * chore(eslint): add licence.template.txt for copyright notice verification
1 parent a070497 commit 736f280

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+997
-765
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 45 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import path from "path";
2+
import { fileURLToPath } from "url";
3+
4+
import { defineConfig, globalIgnores } from "eslint/config";
5+
6+
import tsParser from "@typescript-eslint/parser";
7+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
8+
import unusedImports from "eslint-plugin-unused-imports";
9+
import workspaces from "eslint-plugin-workspaces";
10+
import notice from "eslint-plugin-notice";
11+
import globals from "globals";
12+
import js from "@eslint/js";
13+
import checkFile from "eslint-plugin-check-file";
14+
15+
import extraneousDependencies from "eslint-plugin-import";
16+
import { FlatCompat } from "@eslint/eslintrc";
17+
import nodePlugin from "eslint-plugin-n";
18+
19+
const __filename = fileURLToPath(import.meta.url);
20+
const __dirname = path.dirname(__filename);
21+
22+
const compat = new FlatCompat({
23+
baseDirectory: __dirname,
24+
recommendedConfig: js.configs.recommended,
25+
allConfig: js.configs.all,
26+
});
27+
28+
export default defineConfig([
29+
...compat.extends(
30+
"eslint:recommended",
31+
"prettier",
32+
"plugin:@typescript-eslint/recommended",
33+
"plugin:workspaces/recommended",
34+
"plugin:n/recommended"
35+
),
36+
//
37+
nodePlugin.configs["flat/recommended-script"],
38+
{
39+
languageOptions: {
40+
parser: tsParser,
41+
parserOptions: {
42+
tsconfigRootDir: __dirname,
43+
project: ["./tsconfig.eslint.json"],
44+
},
45+
globals: {
46+
...globals.node,
47+
},
48+
},
49+
plugins: {
50+
"@typescript-eslint": typescriptEslint,
51+
"unused-imports": unusedImports,
52+
workspaces,
53+
notice,
54+
"extraneous-dependencies": extraneousDependencies,
55+
n: nodePlugin,
56+
"check-file": checkFile,
57+
},
58+
59+
rules: {
60+
// *************** Ensure that copyright notice is present ***************
61+
"notice/notice": [
62+
"error",
63+
{
64+
mustMatch: "Copyright \\(c\\) [0-9]{0,4} Contributors to the Eclipse Foundation",
65+
templateFile: __dirname + "/license.template.txt",
66+
onNonMatchingHeader: "replace",
67+
},
68+
],
69+
70+
// *************** NodeJS specific rules - relaxing default setting of n ***************
71+
"n/no-path-concat": "error",
72+
"n/no-unsupported-features/es-syntax": [
73+
"error",
74+
{
75+
ignores: ["modules"],
76+
},
77+
],
78+
79+
// relax missing import rule to warning, as we sometimes have optional dependencies
80+
// import "../foo" will braise a warning ,
81+
// import "../foo.js" is the correct way to import a file that may not exist
82+
"n/no-missing-import": "warn",
83+
84+
"n/no-unsupported-features/node-builtins": "warn",
85+
"n/no-extraneous-import": "warn",
86+
"n/no-deprecated-api": "warn",
87+
"n/no-unpublished-import": "warn",
88+
"n/no-process-exit": "warn",
89+
"n/hashbang": "warn",
90+
91+
// *************** Ensure that only used dependencies are imported ***************
92+
"extraneous-dependencies/no-extraneous-dependencies": "warn",
93+
94+
// *************** Code style and best practices ***************
95+
"unused-imports/no-unused-imports": "error",
96+
"unused-imports/no-unused-vars": [
97+
"warn",
98+
{
99+
args: "none",
100+
varsIgnorePattern: "Test",
101+
},
102+
],
103+
104+
// **************** enforece kebab-case for filenames ****************
105+
"check-file/filename-naming-convention": [
106+
"error",
107+
{
108+
"**/*.{js,ts}": "KEBAB_CASE",
109+
},
110+
{
111+
ignoreMiddleExtensions: true,
112+
},
113+
],
114+
"check-file/folder-naming-convention": [
115+
"error",
116+
{
117+
"**/*": "KEBAB_CASE",
118+
},
119+
],
120+
// *************** Customization of other typescript rules ***************
121+
"@typescript-eslint/no-use-before-define": "error",
122+
"@typescript-eslint/no-unused-vars": "off",
123+
"@typescript-eslint/no-unused-expressions": "off",
124+
"@typescript-eslint/no-require-imports": "warn",
125+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
126+
"@typescript-eslint/no-empty-object-type": "warn",
127+
"@typescript-eslint/no-floating-promises": "warn",
128+
129+
// **************** Enforce usage of `const` over `let` wherever possible, to prevent accidental reassignments
130+
"prefer-const": "warn",
131+
132+
// *************** Other rules ***************
133+
"no-restricted-globals": "error",
134+
"no-restricted-properties": "error",
135+
136+
"no-use-before-define": "error",
137+
138+
"no-unused-private-class-members": "warn",
139+
"no-prototype-builtins": "off",
140+
"no-case-declarations": "off",
141+
142+
"no-console": "error",
143+
// ***************** Enforce that for-in loops include an if statement to filter properties from the prototype chain
144+
"guard-for-in": "error",
145+
},
146+
},
147+
globalIgnores([
148+
"utils/*",
149+
"packages/browser-bundle/types/index.d.ts",
150+
"packages/*/eslint.config.mjs",
151+
"eslint.config.mjs",
152+
"packages/browser-bundle/web-test-runner.config.mjs",
153+
"**/.eslintrc.js",
154+
"**/dist",
155+
"**/node_modules",
156+
"examples",
157+
"**/bin",
158+
"**/*.js",
159+
]),
160+
]);

licence.template.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/********************************************************************************
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License v. 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and
10+
* Document License (2015-05-13) which is available at
11+
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document.
12+
*
13+
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
14+
********************************************************************************/

0 commit comments

Comments
 (0)