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
28 changes: 0 additions & 28 deletions common/.eslintrc.cjs

This file was deleted.

78 changes: 78 additions & 0 deletions common/eslint-config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

import js from '@eslint/js';
import tseslint from 'typescript-eslint';

/**
* Shared ESLint configuration for the Qt VS Code extensions.
*
* `@eslint/js` and `typescript-eslint` are resolved from the monorepo root
* node_modules because this module lives in `common/`.
*
* @param {object} options
* @param {string} options.tsconfigRootDir directory containing the
* tsconfig.json used for
* type-aware linting
*/
export function createConfig({ tsconfigRootDir }) {
return tseslint.config(
{
ignores: ['**/out/**', '**/test/**', '**/webview-ui/**']
},
{
files: ['**/*.ts', '**/*.mts', '**/*.cts'],
extends: [
js.configs.recommended,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked
],
languageOptions: {
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir
}
},
rules: {
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'default-param-last': 'off',
'@typescript-eslint/default-param-last': 'error',
'class-methods-use-this': 'off',
'@typescript-eslint/class-methods-use-this': 'error',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/return-await': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/prefer-find': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/restrict-plus-operands': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ caughtErrors: 'none' }
],
'@typescript-eslint/no-misused-promises': [
'error',
// Async overrides of void-returning base class methods are the
// established pattern for vscode DebugSession request handlers.
{ checksVoidReturn: { inheritedMethods: false } }
],
'@typescript-eslint/prefer-nullish-coalescing': [
'error',
// `x ? x : y` differs from `x ?? y` for falsy non-nullish values,
// so converting ternaries is not behavior preserving.
{ ignoreTernaryTests: true }
],
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ considerDefaultExhaustiveForUnions: true }
],
// Type parameters that appear only in the return type are used as
// intentional cast-style APIs (e.g. CoreAPI.getValue<T>).
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
curly: 'error'
}
}
);
}
40 changes: 7 additions & 33 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
// Copyright (C) 2026 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

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 [
{
ignores: ['eslint.config.mjs']
},
...compat.extends('./common/.eslintrc.cjs'),
{
plugins: {
'@typescript-eslint': typescriptEslint
},
import { createConfig } from './common/eslint-config.mjs';

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname
}
}
}
];
export default createConfig({
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url))
});
Loading
Loading