mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-07-09 17:19:02 +00:00
* Squashed 'packages/mobile-mcp/' content from commit c5d7d27fd git-subtree-dir: packages/mobile-mcp git-subtree-split: c5d7d27fd61e4762e15ae4b1c68b6c011be88bb7 * feat(mobile-mcp): vendor mobile-mcp with opt-in 0-1000 relative coordinates Fork mobile-next/mobile-mcp (v0.0.61) into packages/mobile-mcp/ via git subtree, renamed to @qwen-code/mobile-mcp with the following additions: Relative coordinate shim (src/coord-norm.ts): - MOBILE_MCP_COORDINATE_SPACE=1 enables 0-1000 normalized coordinates - MOBILE_MCP_COORDINATE_SCALE configurable (default 1000, 999 for mobile_use) - Input denormalization for click/double_tap/long_press/swipe - Output normalization for list_elements and get_screen_size - Tool description rewriting when enabled - Default off = zero behavior change Android enhancements: - mobile_install_app: -r/-g/-d/-t install flags (Android only) - mobile_ui_dump: full UIAutomator XML hierarchy dump - mobile_adb_pull / mobile_adb_push: file transfer via ADB Infrastructure: - cd-mobile-mcp.yml: npm publish workflow (tag mobile-mcp-v*) - scripts/sync-from-upstream.sh: git subtree pull for upstream sync - .vendored-from / .vendored-patches.md: vendoring metadata - Upstream telemetry disabled by default - eslint.config.js: exclude packages/mobile-mcp from root lint * chore(mobile-mcp): update package-lock.json for workspace dependencies * fix(mobile-mcp): quote all YAML strings to pass yamllint * fix(mobile-mcp): fix cd workflow yaml to pass both yamllint and actionlint * fix(mobile-mcp): address review findings on our additions - ensureScreenSize: log warning instead of silent failure (#4) - invalidateScreenSize on orientation change (#5) - adb_push: path.posix.resolve to prevent /sdcard/ traversal (#6) - adb_pull: readOnlyHint → destructiveHint (writes local file) (#9) - adb_push: remove validateOutputPath on read-source local_path (#11) - normalizeElementResult: log error instead of bare catch (#16) - rewriteDescription: remove dead duplicate regex (#17) - cd workflow: add test step between build and publish (#19) * fix(mobile-mcp): update server.json identity and fix package.json main entrypoint --------- Co-authored-by: Shaojin Wen <shaojin.wensj@alibaba-inc.com>
384 lines
11 KiB
JavaScript
384 lines
11 KiB
JavaScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import eslint from '@eslint/js';
|
|
import tseslint from 'typescript-eslint';
|
|
import reactPlugin from 'eslint-plugin-react';
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
import prettierConfig from 'eslint-config-prettier';
|
|
import importPlugin from 'eslint-plugin-import';
|
|
import vitest from '@vitest/eslint-plugin';
|
|
import globals from 'globals';
|
|
// For more info, see https://github.com/storybookjs/eslint-plugin-storybook#configuration-flat-config-format
|
|
import storybook from 'eslint-plugin-storybook';
|
|
import checkFile from 'eslint-plugin-check-file';
|
|
import { legacyFilenames } from './eslint.legacy-filenames.mjs';
|
|
|
|
export default tseslint.config(
|
|
{
|
|
// Global ignores
|
|
ignores: [
|
|
'node_modules/*',
|
|
'packages/**/dist/**',
|
|
'bundle/**',
|
|
'package/bundle/**',
|
|
'.integration-tests/**',
|
|
'packages/**/.integration-test/**',
|
|
'dist/**',
|
|
'demo/**/dist/**',
|
|
'docs-site/.next/**',
|
|
'docs-site/out/**',
|
|
'.qwen/**',
|
|
'packages/desktop/**',
|
|
'packages/cua-driver/**', // vendored trycua/cua driver (Rust + scripts); not qwen-code TS
|
|
'packages/mobile-mcp/**', // vendored mobile-next/mobile-mcp; has own eslint config
|
|
],
|
|
},
|
|
eslint.configs.recommended,
|
|
...tseslint.configs.recommended,
|
|
reactHooks.configs['recommended-latest'],
|
|
reactPlugin.configs.flat.recommended,
|
|
reactPlugin.configs.flat['jsx-runtime'], // Add this if you are using React 17+
|
|
{
|
|
// Settings for eslint-plugin-react
|
|
settings: {
|
|
react: {
|
|
version: 'detect',
|
|
},
|
|
},
|
|
},
|
|
{
|
|
// Import specific config
|
|
files: ['packages/cli/src/**/*.{ts,tsx}'], // Target only TS/TSX in the cli package
|
|
plugins: {
|
|
import: importPlugin,
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
node: true,
|
|
},
|
|
},
|
|
rules: {
|
|
...importPlugin.configs.recommended.rules,
|
|
...importPlugin.configs.typescript.rules,
|
|
'import/no-default-export': 'warn',
|
|
'import/no-unresolved': 'off', // Disable for now, can be noisy with monorepos/paths
|
|
'import/namespace': 'off', // Disabled due to https://github.com/import-js/eslint-plugin-import/issues/2866
|
|
},
|
|
},
|
|
{
|
|
// General overrides and rules for the project (TS/TSX files)
|
|
files: ['packages/**/src/**/*.{ts,tsx}'], // Target TS/TSX in all packages (including nested)
|
|
plugins: {
|
|
import: importPlugin,
|
|
},
|
|
settings: {
|
|
'import/resolver': {
|
|
node: true,
|
|
},
|
|
},
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
...globals.es2021,
|
|
},
|
|
},
|
|
rules: {
|
|
// We use TypeScript for React components; prop-types are unnecessary
|
|
'react/prop-types': 'off',
|
|
// General Best Practice Rules (subset adapted for flat config)
|
|
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
|
|
'arrow-body-style': ['error', 'as-needed'],
|
|
curly: ['error', 'multi-line'],
|
|
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
'@typescript-eslint/consistent-type-assertions': [
|
|
'error',
|
|
{ assertionStyle: 'as' },
|
|
],
|
|
'@typescript-eslint/explicit-member-accessibility': [
|
|
'error',
|
|
{ accessibility: 'no-public' },
|
|
],
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
'@typescript-eslint/no-inferrable-types': [
|
|
'error',
|
|
{ ignoreParameters: true, ignoreProperties: true },
|
|
],
|
|
'@typescript-eslint/consistent-type-imports': [
|
|
'error',
|
|
{ disallowTypeAnnotations: false },
|
|
],
|
|
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: true }],
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
'import/no-internal-modules': [
|
|
'error',
|
|
{
|
|
allow: [
|
|
'react-dom/test-utils',
|
|
'react-dom/client',
|
|
'memfs/lib/volume.js',
|
|
'mime/lite',
|
|
'yargs/**',
|
|
'msw/node',
|
|
'**/generated/**',
|
|
'./styles/tailwind.css',
|
|
'./styles/App.css',
|
|
'./styles/style.css'
|
|
],
|
|
},
|
|
],
|
|
'import/no-relative-packages': 'error',
|
|
'no-cond-assign': 'error',
|
|
'no-debugger': 'error',
|
|
'no-duplicate-case': 'error',
|
|
'no-restricted-syntax': [
|
|
'error',
|
|
{
|
|
selector: 'CallExpression[callee.name="require"]',
|
|
message: 'Avoid using require(). Use ES6 imports instead.',
|
|
},
|
|
{
|
|
selector: 'ThrowStatement > Literal:not([value=/^\\w+Error:/])',
|
|
message:
|
|
'Do not throw string literals or non-Error objects. Throw new Error("...") instead.',
|
|
},
|
|
],
|
|
'no-unsafe-finally': 'error',
|
|
'no-console': 'error',
|
|
'no-unused-expressions': 'off', // Disable base rule
|
|
'@typescript-eslint/no-unused-expressions': [
|
|
// Enable TS version
|
|
'error',
|
|
{ allowShortCircuit: true, allowTernary: true },
|
|
],
|
|
'no-var': 'error',
|
|
'object-shorthand': 'error',
|
|
'one-var': ['error', 'never'],
|
|
'prefer-arrow-callback': 'error',
|
|
'prefer-const': ['error', { destructuring: 'all' }],
|
|
radix: 'error',
|
|
'default-case': 'error',
|
|
},
|
|
},
|
|
{
|
|
// Enforce kebab-case filenames
|
|
files: ['packages/core/src/**/*.ts', 'packages/cli/src/**/*.ts'],
|
|
ignores: legacyFilenames.flatMap((name) => [
|
|
`**/${name}.ts`,
|
|
`**/${name}.*.ts`,
|
|
]),
|
|
plugins: {
|
|
'check-file': checkFile,
|
|
},
|
|
rules: {
|
|
'check-file/filename-naming-convention': [
|
|
'error',
|
|
{ '**/*.ts': 'KEBAB_CASE' },
|
|
{ ignoreMiddleExtensions: true },
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: ['packages/*/src/**/*.test.{ts,tsx}', 'packages/**/test/**/*.test.{ts,tsx}'],
|
|
plugins: {
|
|
vitest,
|
|
},
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.vitest,
|
|
},
|
|
},
|
|
rules: {
|
|
...vitest.configs.recommended.rules,
|
|
'vitest/expect-expect': 'off',
|
|
'vitest/no-commented-out-tests': 'off',
|
|
'no-console': 'off', // Allow console in tests
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
// extra settings for scripts that we run directly with node
|
|
{
|
|
files: [
|
|
'./scripts/**/*.js',
|
|
'./scripts/**/*.mjs',
|
|
'esbuild.config.js',
|
|
'packages/*/scripts/**/*.js',
|
|
// Verification reproducer scripts under docs/ also run with `node`.
|
|
'docs/**/*.mjs',
|
|
// Plan C CDP-tunnel acceptance harness (issue #5626) runs with `node`.
|
|
'packages/cli/src/serve/cdp-tunnel/acceptance/**/*.mjs',
|
|
],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
...globals.browser,
|
|
process: 'readonly',
|
|
console: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'no-console': 'off', // Allow console in scripts
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: ['**/*.cjs'],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
module: 'readonly',
|
|
require: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
'no-undef': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['.github/scripts/**/*.{js,mjs,cjs}'],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
// ==================== no-console allowlist ====================
|
|
// The following files/packages are allowed to use console.*
|
|
|
|
// VS Code IDE companion - out of scope for no-console rule
|
|
{
|
|
files: ['packages/vscode-ide-companion/**/*.ts', 'packages/vscode-ide-companion/**/*.tsx', 'packages/vscode-ide-companion/**/*.js'],
|
|
rules: { 'no-console': 'off' },
|
|
},
|
|
// WebUI package - UI component library with Storybook
|
|
{
|
|
files: ['packages/webui/**/*.ts', 'packages/webui/**/*.tsx', 'packages/webui/**/*.js'],
|
|
rules: { 'no-console': 'off' },
|
|
},
|
|
// Chrome extension (chrome-extension) - the MV3 background service
|
|
// worker and content scripts run in the browser with no stdio; console is
|
|
// the only logging / debugging channel available there.
|
|
{
|
|
files: ['packages/chrome-extension/**/*.ts', 'packages/chrome-extension/**/*.tsx'],
|
|
rules: { 'no-console': 'off' },
|
|
},
|
|
// Specific CLI files that intentionally wrap console usage
|
|
{
|
|
files: [
|
|
'packages/cli/src/acp-integration/acpAgent.ts', // console infrastructure for ACP mode
|
|
'packages/cli/src/utils/stdioHelpers.ts', // wraps console.clear()
|
|
],
|
|
rules: { 'no-console': 'off' },
|
|
},
|
|
// Specific esbuild configs not covered by scripts pattern
|
|
{
|
|
files: ['packages/vscode-ide-companion/esbuild.js'],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
process: 'readonly',
|
|
console: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'no-restricted-syntax': 'off',
|
|
'@typescript-eslint/no-require-imports': 'off',
|
|
'no-console': 'off',
|
|
},
|
|
},
|
|
// Settings for web-templates assets
|
|
{
|
|
files: [
|
|
'packages/web-templates/src/**/*.{js,jsx,ts,tsx}',
|
|
'packages/web-templates/*.mjs',
|
|
],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
'react/react-in-jsx-scope': 'off',
|
|
'react/prop-types': 'off',
|
|
'no-console': 'off',
|
|
'no-undef': 'off',
|
|
},
|
|
},
|
|
// Prettier config must be last
|
|
prettierConfig,
|
|
// extra settings for scripts that we run directly with node
|
|
{
|
|
files: ['./integration-tests/**/*.{js,ts,tsx}'],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.node,
|
|
process: 'readonly',
|
|
console: 'readonly',
|
|
},
|
|
},
|
|
rules: {
|
|
'no-console': 'off', // Allow console in integration tests
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{
|
|
argsIgnorePattern: '^_',
|
|
varsIgnorePattern: '^_',
|
|
caughtErrorsIgnorePattern: '^_',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
// Settings for docs-site directory
|
|
{
|
|
files: ['docs-site/**/*.{js,jsx}'],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
parserOptions: {
|
|
ecmaFeatures: {
|
|
jsx: true,
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
// Allow relaxed rules for documentation site
|
|
'@typescript-eslint/no-unused-vars': 'off',
|
|
'react/prop-types': 'off',
|
|
'react/react-in-jsx-scope': 'off',
|
|
},
|
|
},
|
|
storybook.configs['flat/recommended'],
|
|
);
|