More levels of categorization
See original GitHub issueCurrently type detection possible if file will be located in specific folder. It’s kind of old type of separation: type of file in one folder: controllers, models, views, etc. But, there are projects where grouping is happen by feature: Angular X, NestJS (three layered architecture).
Example 1: https://github.com/nestjs/nest/blob/master/sample/01-cats-app/src/app.module.ts
import { Module } from '@nestjs/common';
import { CatsModule } from './cats/cats.module';
import { CoreModule } from './core/core.module';
@Module({
imports: [CoreModule, CatsModule],
})
export class AppModule {}
Module can import other modules.
And another issue, example 2: https://github.com/nestjs/nest/blob/2525e9406d8f4a4c16c973320176564b447a860f/sample/01-cats-app/src/cats/cats.module.ts
import { Module } from '@nestjs/common';
import { CatsController } from './cats.controller';
import { CatsService } from './cats.service';
@Module({
controllers: [CatsController],
providers: [CatsService],
})
export class CatsModule {}
Module can import other modules and any components of own feature, but can not import components of other modules (we can’t import FoodService here)
https://github.com/nestjs/nest/blob/2525e9406d8f4a4c16c973320176564b447a860f/sample/01-cats-app/src/cats/cats.service.ts
cat.service
can import others services and cat.repository
, and cannot import other repositories (e.g. food.repository
)
Looks like, currently it’s not possible to configure plugin in such way. So, besides of type, this requires to detect another attribute of the file - feature (sub module, group).
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (10 by maintainers)
Hi again, I think I have a simpler but still powerful enough solution.
In
settings
,types
could be defined as simple strings, as currently, or as an object containingname
and aglob
pattern. It would be also possible to definecapture
, as in the previous examples, but maintaining the standardglob
expressions (it would be used the micromatchcapture
method) to capture all matches in pattern, and users could give a name to each capture in the same order that they will be received:Doing it this way, settings would be backward compatible, and could be still defined as strings for simple scenarios, or as objects for more complex ones. The pattern for strings would be assigned internally to
**/[string]/*
, so it would match any folder named as the string value, as the plugin currently does.The other part is how to define allowed types. In this case, it is required a change in the configuration, which currently receives an object. It should receive an array of objects with the keys
from
andallows
, but maintaining the same simplicity that current settings, so users could define from which elements can be imported other elements using an array of strings in theallow
property:Then, for more complex scenarios, the plugin would give the possibility to use an array with options instead of a string when defining
from
, andallow
types. The array would have the element type in the first position, and an object with options to usecaptures
in the second one, so it could be specified thecapture
values that should have to be applied for that rule, both infrom
ortarget
types.I still have to write an example of the configurations for the @unlight’s requirements using this pattern, but I think it could be done easier and simpler than in the previous proposal, and in my opinion the resultant configuration would be more readable.
@unlight Ok, I didn’t understand.
You’re right, my fault. It does not support multiple patterns in the
pattern
property ofboundaries/elements
setting. But I think it should, because it could be a good solution for some cases, as in your example. Tomorrow I will publish v2.0.0-beta.4 adding the feature. I will also add unit tests based on your second example, in order to know what can be happening.