Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): improve no-accumulating-spread (#5302)
VSCode has a couple violations. examples: ``` x oxc(no-accumulating-spread): Do not spread accumulators in loops ,-[src/vs/workbench/services/textMate/common/TMGrammarFactory.ts:65:5] 64 | let injections: string[] = []; 65 | for (let i = 1; i <= scopeParts.length; i++) { : ^|^ : `-- For this loop 66 | const subScopeName = scopeParts.slice(0, i).join('.'); 67 | injections = [...injections, ...(this._injections[subScopeName] || [])]; : ^^^^^^|^^^^^^ : `-- From this spread 68 | } `---- help: Consider using `Object.assign()` or `Array.prototype.push()` to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. x oxc(no-accumulating-spread): Do not spread accumulators in loops ,-[src/vs/base/common/actions.ts:205:3] 204 | let out: IAction[] = []; 205 | for (const list of actionLists) { : ^|^ : `-- For this loop 206 | if (!list.length) { 207 | // skip 208 | } else if (out.length) { 209 | out = [...out, new Separator(), ...list]; : ^^^|^^ : `-- From this spread 210 | } else { `---- help: Consider using `Object.assign()` or `Array.prototype.push()` to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. help: It looks like you're spreading an `Array`. Consider using the `Array.push` or `Array.concat` methods to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. x oxc(no-accumulating-spread): Do not spread accumulators in loops ,-[src/vs/workbench/contrib/extensions/browser/extensionsActions.ts:302:3] 301 | let actions: IAction[] = []; 302 | for (const visibleActions of actionsGroups) { : ^|^ : `-- For this loop 303 | if (visibleActions.length) { 304 | actions = [...actions, ...visibleActions, new Separator()]; : ^^^^^|^^^^ : `-- From this spread 305 | } `---- help: Consider using `Object.assign()` or `Array.prototype.push()` to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. x oxc(no-accumulating-spread): Do not spread accumulators in loops ,-[src/vs/workbench/contrib/extensions/browser/extensionsActions.ts:1141:3] 1140 | let actions: IAction[] = []; 1141 | for (const menuActions of menuActionGroups) { : ^|^ : `-- For this loop 1142 | actions = [...actions, ...menuActions, new Separator()]; : ^^^^^|^^^^ : `-- From this spread 1143 | } `---- help: Consider using `Object.assign()` or `Array.prototype.push()` to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. x oxc(no-accumulating-spread): Do not spread accumulators in loops ,-[src/vs/workbench/contrib/extensions/browser/extensionsViews.ts:334:4] 333 | let actions: IAction[] = []; 334 | for (const menuActions of groups) { : ^|^ : `-- For this loop 335 | actions = [...actions, ...menuActions, new Separator()]; : ^^^^^|^^^^ : `-- From this spread 336 | } `---- help: Consider using `Object.assign()` or `Array.prototype.push()` to mutate the accumulator instead. Using spreads within accumulators leads to `O(n^2)` time complexity. ```
- Loading branch information