feature-sliced / steiger

Universal file structure and project architecture linter
https://www.npmjs.com/package/steiger
MIT License
65 stars 4 forks source link

Feature request: add settings for current rules #33

Closed noveogroup-amorgunov closed 1 month ago

noveogroup-amorgunov commented 3 months ago

Hey. I have a feature request: setup current rules from config file. For example, turn off some layers for "forbidden-import" rule.

 ✘ Forbidden cross-import on layer "entities" from "wishlist/model/slice.ts" to slice "product".  // forbidden-imports

 ✘ Forbidden cross-import on layer "entities" from "wishlist/lib/mapWishlist.ts" to slice "product".  // forbidden-imports

 ✘ Forbidden cross-import on layer "entities" from "wishlist/api/types.ts" to slice "product".  // forbidden-imports

 ✘ Forbidden cross-import on layer "entities" from "wishlist/api/wishlistApi.ts" to slice "product".  // forbidden-imports

 ✘ Forbidden cross-import on layer "entities" from "theme/lib/ThemeProvider.tsx" to slice "featureToggle".  // forbidden-imports

 ✘ Forbidden cross-import on layer "entities" from "category/model/types.ts" to slice "product".  // forbidden-imports

It could look like this:

export default defineConfig({
  rules: {
    'forbidden-imports': ['on', {
      ignoreLayers: ['entities']
    }],
  },
})
illright commented 3 months ago

This is definitely something that we should support, however, the exact API is a hot topic for discussion. I'll say up front that I am now tending towards a JS-only (no JSON or YAML) config, much in the same way as ESLint's new flat config format. I think it gives great flexibility. I will think of the specifics and probably create a discussion on GitHub asking for feedback. Would love to hear your take on it as well. I will let you know when I post it

illright commented 2 months ago

@noveogroup-amorgunov @EliseyMartynov I've finally got around to writing up the proposed config format. You can leave feedback in this discussion as well as possibly suggest alternative formats. No need to be as detailed, even just ideas are good additions too.

https://github.com/feature-sliced/steiger/discussions/53

illright commented 1 month ago

Let's track this in #69 (nice)