Skip to content

Add option to ignore files outside the workspace - #2227

Open
QinXi (QinXi-ai) wants to merge 3 commits into
microsoft:mainfrom
QinXi-ai:codex/limit-lint-to-workspace
Open

Add option to ignore files outside the workspace#2227
QinXi (QinXi-ai) wants to merge 3 commits into
microsoft:mainfrom
QinXi-ai:codex/limit-lint-to-workspace

Conversation

@QinXi-ai

Copy link
Copy Markdown

Problem

Opening a local file outside the current workspace can make the extension load and run an unrelated ESLint configuration. The existing behavior is useful for single-file workflows, so changing it unconditionally would break compatibility.

Design

  • Add an opt-in eslint.ignoreOutsideWorkspace resource setting, defaulting to false.
  • When enabled and at least one workspace folder is open, skip local file: documents that do not belong to any workspace folder.
  • Keep untitled and virtual documents unchanged, and keep standalone-file validation working when no folder is open.
  • Apply the boundary before explicit eslint.validate rules so the option consistently blocks external files.
  • Re-evaluate synced documents when workspace folders are added or removed, in addition to configuration changes.
  • Extract the validator behind a small injectable workspace interface so boundary behavior can be tested without a VS Code host.

Tests

  • npm run compile
  • npm run lint
  • npm test (client: 7 passed; server: 5 passed)

Fixes #1805

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@QinXi-ai

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Comment thread client/src/validator.ts Outdated
Comment thread client/src/validator.ts
@QinXi-ai

Copy link
Copy Markdown
Author

Addressed both review points in 70c63af:

  • replaced the hand-written workspace interfaces with a Pick of the VS Code workspace API
  • applied ignoreOutsideWorkspace to remote and virtual workspace documents while leaving untitled documents under ignoreUntitled
  • added remote in-workspace and outside-workspace coverage and updated the setting documentation

Validation: client TypeScript compile passed, all 9 client tests passed, and client/server lint passed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Virtual documents are incorrectly excluded, and workspace-folder transitions leave document synchronization state inconsistent.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds opt-in workspace-boundary filtering for ESLint validation while preserving standalone-file behavior.

Changes:

  • Adds and documents eslint.ignoreOutsideWorkspace.
  • Extracts validation logic into an injectable, tested validator.
  • Refreshes document synchronization when workspace folders change.
File summaries
File Description
$shared/settings.ts Adds the shared setting type.
package.json Declares the resource setting.
README.md Documents the option.
client/src/validator.ts Implements workspace-boundary validation.
client/src/tests/validator.test.ts Tests boundary behavior.
client/src/extension.ts Uses the validator during activation.
client/src/client.ts Refreshes synchronization and sends settings.
server/src/eslint.ts Adds the server-side default.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread client/src/client.ts
Comment thread client/src/validator.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not lint outside current project workspace directory

3 participants