beachball icon indicating copy to clipboard operation
beachball copied to clipboard

feat: ignore parts of json file when running `change`

Open Hotell opened this issue 3 years ago • 0 comments

Current behaviour

We use fine grained glob list of ignorePatterns to provide less distracted experience to contributors - only to require change files when they are really needed.

Example:

ignorePatterns: [
    '**/*.{shot,snap}',
    '**/*.{test,spec}.{ts,tsx}',
    '**/*.stories.tsx',
    '**/__fixtures__/**',
    '**/__mocks__/**',
    '**/common/isConformant.ts',
    '**/jest.config.js',
    '**/SPEC*.md',
    '**/tests/**',
  ],

While this is great, it this falls short is when we update part of json files like scripts or devDependencies which have nothing to do with triggering a change.

New behaviour/Feature request:

  • it would be great to add functionality where one can define which part of json files should/should not trigger a change as sell

Propsoed API

- type IgnorePatterns = Array<string>
+ type IgnorePatterns = Array<string | { jsonGlob: string, keys: Array<string> }>

Example:

ignorePatterns: [
    '**/*.{shot,snap}',
    '**/*.{test,spec}.{ts,tsx}',
    '**/*.stories.tsx',
    '**/__fixtures__/**',
    '**/__mocks__/**',
    '**/common/isConformant.ts',
    '**/jest.config.js',
    '**/SPEC*.md',
    '**/tests/**'

    // 🛠 New API usage
    {
         jsonGlob: '**/package.json', 
         keys: [ 'scripts', 'devDependencies' ] 
    }
  ],

Open to any suggestions ofc

Validation:

  • if user would use this new api for file/glob that doesn't have json extension, CLI will throw error
    • {jsonGlob: '**/SPEC*.md'} - throw Error 🚨
    • {jsonGlob: '**/SPEC*.md',keys: ['foo'] } - throw Error 🚨

thx!

Hotell avatar Jan 13 '22 13:01 Hotell