dolsem / eslint-plugin-filename-rules

MIT License
36 stars 7 forks source link

Custom error/warning message? #9

Open areknow opened 2 years ago

areknow commented 2 years ago

Is it possible to pass in a custom error message? Maybe something like this:

{
    files: ['foo/bar/*.ts'],
    rules: {
        'filename-rules/match': [
            'error',
            {
                regex: /(.*?)\.(get\.ts|post\.ts)$/,
                message: 'Files extensions must follow the convention of: {.get.ts, .post.ts}'
            }
        ]
    }
}
brandonbrown5 commented 1 year ago

I've created at PR here to accomplish this: https://github.com/dolsem/eslint-plugin-filename-rules/pull/12

Here, you could specify the message as a third argument:

...
'filename-rules/match': [2, /^([a-z]+-)*[a-z]+(?:\..*)?$/], 'Custom message',
...

Didn't want to mess up anyone's use of this library by changing the structure of the rules input.