Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

45 changes: 0 additions & 45 deletions .eslintrc.js

This file was deleted.

160 changes: 160 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
import path from "path";
import { fileURLToPath } from "url";

import { defineConfig, globalIgnores } from "eslint/config";

import tsParser from "@typescript-eslint/parser";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import unusedImports from "eslint-plugin-unused-imports";
import workspaces from "eslint-plugin-workspaces";
import notice from "eslint-plugin-notice";
import globals from "globals";
import js from "@eslint/js";
import checkFile from "eslint-plugin-check-file";

import extraneousDependencies from "eslint-plugin-import";
import { FlatCompat } from "@eslint/eslintrc";
import nodePlugin from "eslint-plugin-n";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default defineConfig([
...compat.extends(
"eslint:recommended",
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:workspaces/recommended",
"plugin:n/recommended"
),
//
nodePlugin.configs["flat/recommended-script"],
{
languageOptions: {
parser: tsParser,
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.eslint.json"],
},
globals: {
...globals.node,
},
},
plugins: {
"@typescript-eslint": typescriptEslint,
"unused-imports": unusedImports,
workspaces,
notice,
"extraneous-dependencies": extraneousDependencies,
n: nodePlugin,
"check-file": checkFile,
},

rules: {
// *************** Ensure that copyright notice is present ***************
"notice/notice": [
"error",
{
mustMatch: "Copyright \\(c\\) [0-9]{0,4} Contributors to the Eclipse Foundation",
templateFile: __dirname + "/license.template.txt",
onNonMatchingHeader: "replace",
},
],

// *************** NodeJS specific rules - relaxing default setting of n ***************
"n/no-path-concat": "error",
"n/no-unsupported-features/es-syntax": [
"error",
{
ignores: ["modules"],
},
],

// relax missing import rule to warning, as we sometimes have optional dependencies
// import "../foo" will braise a warning ,
// import "../foo.js" is the correct way to import a file that may not exist
"n/no-missing-import": "warn",

"n/no-unsupported-features/node-builtins": "warn",
"n/no-extraneous-import": "warn",
"n/no-deprecated-api": "warn",
"n/no-unpublished-import": "warn",
"n/no-process-exit": "warn",
"n/hashbang": "warn",

// *************** Ensure that only used dependencies are imported ***************
"extraneous-dependencies/no-extraneous-dependencies": "warn",

// *************** Code style and best practices ***************
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"warn",
{
args: "none",
varsIgnorePattern: "Test",
},
],

// **************** enforece kebab-case for filenames ****************
"check-file/filename-naming-convention": [
"error",
{
"**/*.{js,ts}": "KEBAB_CASE",
},
{
ignoreMiddleExtensions: true,
},
],
"check-file/folder-naming-convention": [
"error",
{
"**/*": "KEBAB_CASE",
},
],
// *************** Customization of other typescript rules ***************
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-require-imports": "warn",
"@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/no-empty-object-type": "warn",
"@typescript-eslint/no-floating-promises": "warn",

// **************** Enforce usage of `const` over `let` wherever possible, to prevent accidental reassignments
"prefer-const": "warn",

// *************** Other rules ***************
"no-restricted-globals": "error",
"no-restricted-properties": "error",

"no-use-before-define": "error",

"no-unused-private-class-members": "warn",
"no-prototype-builtins": "off",
"no-case-declarations": "off",

"no-console": "error",
// ***************** Enforce that for-in loops include an if statement to filter properties from the prototype chain
"guard-for-in": "error",
},
},
globalIgnores([
"utils/*",
"packages/browser-bundle/types/index.d.ts",
"packages/*/eslint.config.mjs",
"eslint.config.mjs",
"packages/browser-bundle/web-test-runner.config.mjs",
"**/.eslintrc.js",
"**/dist",
"**/node_modules",
"examples",
"**/bin",
"**/*.js",
]),
]);
14 changes: 14 additions & 0 deletions licence.template.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/********************************************************************************
* Copyright (c) 2025 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the W3C Software Notice and
* Document License (2015-05-13) which is available at
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document.
*
* SPDX-License-Identifier: EPL-2.0 OR W3C-20150513
********************************************************************************/
Loading
Loading