p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

Feature: Exclude directories from mass refactorings #11

Closed mjunker closed 2 years ago

mjunker commented 2 years ago

Hello

Is it possible to exclude some directories from mass refactorings? I only found a way to exclude files by adding the annotation but ignore entire folders does not seem to be possible?

Thanks

lgrammel commented 2 years ago

Hi @mjunker ,

right now this is not possible - they best approach would be to run the mass refactoring on the subfolders that should be included (e.g. src).

That being said, this is a high-priority feature that I want to implement in the next weeks. Right now I'm trying to understand the different use cases better to come up with a good first implementation (since changing configs is always a backwards compatibility issue). The use cases I've seen so far include excluding directories such as node_modules, and to have different configurations for different teams that own subfolders (in a mono repo).

I would love to understand what kind of directories are you trying to exclude and why? Would this exclusion need to apply for all refactorings or just a subset?

Best, Lars

mjunker commented 2 years ago

Hey

Thanks for your reply. Will try this.

Yeah I would like to exclude dist folders and node_modules mainly, but also have a project where I have to commit some third party code into the repo which I don't want to touch. Also generated configuration files I probably would want to exclude. I'm working with a Nx Monorepo which doesn't have a single src folder, but multiple top level folders, which makes it a bit more cumbersome if I have to run the mass refactoring on multiple top level folders individually.

For me the best solution would be a global exclude for all refactorings, something like a .gitignore file would work really well for me.

Best Matt

lgrammel commented 2 years ago

Thanks! Right now I'm thinking the following solution might work:

In p42.toml (to keep the number of config files low):

# Exclusion globs (for refactoring & mass refactoring)
excludedPathPatterns = [
    "**/node_modules/**",
    "**/dist/**",
    "some/other/directory/**",
    "**/generateConfig.js"
]

This would affect both mass refactorings and in-editor refactoring suggestions (which would not be shown for the excluded files).

Would this solution work for you?

mjunker commented 2 years ago

Yes sounds great!

lgrammel commented 2 years ago

Hi @mjunker - I've implemented the feature in version 1.78.0. Please re-open this issue if the solution doesn't work for you.

Thanks again for the suggestion!