Skip to content

Recycle removed items by default - #7568

Merged
MartinM85 merged 3 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-issue-7110-implementation
Sep 13, 2026
Merged

MartinM85 merged 3 commits into
pnp:mainfrom
waldekmastykarz:waldekmastykarz-issue-7110-implementation

Conversation

@waldekmastykarz

Copy link
Copy Markdown
Member

Closes #7110

Updates destructive commands that support recycling to recycle by default and replaces --recycle/--skipRecycleBin with --permanent. Includes updated tests, telemetry, option typing, and documentation for all affected commands.

Validation

  • nrb: passes
  • nt: 16,096 tests pass; the command exits on the existing upstream coverage gap in src/utils/fsUtil.ts lines 82-89 (99.99% global coverage)

@waldekmastykarz waldekmastykarz added the pr-major PR for the next major release label Sep 2, 2026
@MartinM85
MartinM85 requested a lite review from Copilot September 4, 2026 13:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

A few updated commands need small consistency fixes (option typing completeness and quoting/prompt clarity) that could otherwise cause linting or parsing issues.

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

Pull request overview

This PR updates multiple destructive “remove” commands across the CLI to recycle items by default and introduces a consistent --permanent switch for irreversible deletion, aligning behavior with the safety goals in #7110.

Changes:

  • Inverted default deletion behavior to recycle when supported, and replaced --recycle / --skipRecycleBin with --permanent.
  • Updated telemetry, option typing, and command logic to reflect the new semantics.
  • Updated unit tests and command reference docs for all affected commands.
File summaries
File Description
src/m365/spo/commands/site/site-remove.ts Renames --skipRecycleBin to --permanent and updates logic/telemetry/types accordingly.
src/m365/spo/commands/site/site-remove.spec.ts Updates tests to use permanent option name and revised validation expectations.
src/m365/spo/commands/page/page-remove.ts Switches default behavior to recycle; uses --permanent to delete.
src/m365/spo/commands/page/page-remove.spec.ts Updates tests to reflect the new --permanent flag semantics.
src/m365/spo/commands/listitem/listitem-remove.ts Switches default behavior to recycle; replaces --recycle with --permanent.
src/m365/spo/commands/listitem/listitem-remove.spec.ts Updates tests for default recycle behavior and the --permanent flag.
src/m365/spo/commands/listitem/listitem-batch-remove.ts Switches batch remove default to recycle; replaces --recycle with --permanent.
src/m365/spo/commands/listitem/listitem-batch-remove.spec.ts Updates tests to reflect default recycle behavior and --permanent.
src/m365/spo/commands/list/list-remove.ts Switches list removal default to recycle; replaces --recycle with --permanent.
src/m365/spo/commands/list/list-remove.spec.ts Updates tests for new default behavior and option name.
src/m365/spo/commands/folder/folder-remove.ts Switches folder removal default to recycle; replaces --recycle with --permanent.
src/m365/spo/commands/folder/folder-remove.spec.ts Updates tests to match the new default behavior and --permanent.
src/m365/spo/commands/file/file-remove.ts Switches file removal default to recycle; replaces --recycle with --permanent.
src/m365/spo/commands/file/file-remove.spec.ts Updates tests for default recycle behavior and --permanent.
src/m365/spe/commands/container/container-remove.ts Switches default behavior to recycle (DELETE) and uses --permanent for permanentDelete.
src/m365/spe/commands/container/container-remove.spec.ts Updates tests for new default behavior and --permanent.
src/m365/entra/commands/m365group/m365group-remove.ts Replaces --skipRecycleBin with --permanent and updates follow-up permanent removal steps.
src/m365/entra/commands/m365group/m365group-remove.spec.ts Updates tests to use --permanent and validates updated flow.
docs/docs/cmd/spo/site/site-remove.mdx Documents --permanent replacing --skipRecycleBin.
docs/docs/cmd/spo/page/page-remove.mdx Documents --permanent replacing --recycle and updates examples.
docs/docs/cmd/spo/listitem/listitem-remove.mdx Documents --permanent and adds a permanent-delete example.
docs/docs/cmd/spo/listitem/listitem-batch-remove.mdx Documents --permanent and adds a permanent-delete example.
docs/docs/cmd/spo/list/list-remove.mdx Documents --permanent replacing --recycle and updates examples.
docs/docs/cmd/spo/folder/folder-remove.mdx Documents --permanent replacing --recycle and updates examples.
docs/docs/cmd/spo/file/file-remove.mdx Documents --permanent replacing --recycle and updates examples.
docs/docs/cmd/spe/container/container-remove.mdx Documents --permanent replacing --recycle and updates examples.
docs/docs/cmd/entra/m365group/m365group-remove.mdx Documents --permanent replacing --skipRecycleBin and updates remarks/examples.
Review details

Suppressed comments (2)

src/m365/spo/commands/listitem/listitem-remove.ts:162

  • Use single quotes for string literals inside the template expression to match the project’s command-file quoting convention (and avoid lint issues).
      const result = await cli.promptForConfirmation({ message: `Are you sure you want to ${args.options.permanent ? "permanently remove" : "recycle"} the list item ${args.options.id} from list ${args.options.listId || args.options.listTitle || args.options.listUrl} located in site ${args.options.webUrl}?` });

src/m365/spo/commands/listitem/listitem-batch-remove.ts:193

  • Use single quotes for the string literals in this ternary to match the project’s command-file quoting convention.
      const result = await cli.promptForConfirmation({ message: `Are you sure you want to ${args.options.permanent ? "permanently remove" : "recycle"} the list items from list ${args.options.listId || args.options.listTitle || args.options.listUrl} located in site ${args.options.webUrl}?` });
  • Files reviewed: 27/27 changed files
  • Comments generated: 4
  • Review effort level: Lite

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

Comment thread src/m365/spo/commands/listitem/listitem-batch-remove.ts Outdated
Comment thread src/m365/spo/commands/listitem/listitem-remove.ts
Comment thread src/m365/spe/commands/container/container-remove.ts Outdated
Comment thread src/m365/spo/commands/folder/folder-remove.ts Outdated
@MartinM85
MartinM85 marked this pull request as draft September 5, 2026 08:02
@waldekmastykarz
waldekmastykarz marked this pull request as ready for review September 9, 2026 07:08

@MartinM85 MartinM85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @waldekmastykarz,
looks good overall, just one question.
Shouldn't we leave the skipRecycleBin option as a deprecated alias?

@MartinM85 MartinM85 self-assigned this Sep 10, 2026
@MartinM85
MartinM85 marked this pull request as draft September 10, 2026 12:56
waldekmastykarz and others added 3 commits September 11, 2026 11:34
Closes pnp#7110

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Adds force to types.boolean in listitem-batch-remove and listitem-remove
- Updates container-remove confirmation prompt to clarify recycle behavior
- Uses single quotes in string literals for consistency

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@waldekmastykarz

Copy link
Copy Markdown
Member Author

Kept --skipRecycleBin as a deprecated alias for both affected commands. It now maps to --permanent, emits a deprecation warning, and is covered in tests and documentation. The branch has also been rebased on the latest main; nrb and nt pass with 100% coverage.

@waldekmastykarz
waldekmastykarz force-pushed the waldekmastykarz-issue-7110-implementation branch from ef238d2 to 248e439 Compare September 11, 2026 09:35
@waldekmastykarz
waldekmastykarz marked this pull request as ready for review September 11, 2026 09:35

@MartinM85 MartinM85 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice work. 🚀
Approved

@MartinM85
MartinM85 merged commit 12fd91f into pnp:main Sep 13, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-major PR for the next major release pr-merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove commands recycle items by default

3 participants