dolsem / eslint-plugin-filename-rules

MIT License
36 stars 8 forks source link

Allow for specialized file extensions #10

Closed the21st closed 1 year ago

the21st commented 2 years ago

I defined this rule for my repo:

'filename-rules/match': [2, { '.ts': 'camelCase', '.styles.ts': 'PascalCase' }],

Actual result:

/Users/simon/Code/repo/src/MyComponent.styles.ts
  1:1  error  Filename 'MyComponent.styles.ts' does not match camelCase  filename-rules/match

Expected result:

MyComponent should be checked to conform to PascalCase, which it does.

kenberkeley commented 2 years ago

@the21st How about making use of ESLint's overrides:

rules: {
  'filename-rules/match': ['error', { '.ts': 'camelCase' }]
},
overrides: [
  {
    files: ['*.styles.ts'],
    rules: {
      'filename-rules/match': ["error", 'PascalCase']
    }
  }
]