Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup filename and extension extraction to handle dotfile filenames #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jawish
Copy link

@jawish jawish commented Nov 24, 2020

Related issue numbers

About the pull request

Fixes filename and extension extraction so that dotfile filenames are handled.

Additional context

It was previously throwing a 'The filename is empty' errors on dotfiles (e.g.: .eslintrc.js) and the 'excepts' option could not be used to suppress this because the filename length check validation occurs prior.

@codeclimate
Copy link

codeclimate bot commented Nov 24, 2020

Code Climate has analyzed commit 2a98dca and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (60% is the threshold).

This pull request will bring the total coverage in the repository to 95.3% (0.0% change).

View more on Code Climate.

@epaew
Copy link
Owner

epaew commented Nov 24, 2020

Thank you for your contribution.
However, the behavior caused by this change is not what I want.

e.g. I think the extension of index.d.ts is .d.ts, not .ts.

I think it's a problem that the plugin can't lint filenames that start with a dot, so I'd like to fix it.

@@ -9,6 +9,7 @@ ruleTester.run('naming-convention', namingConvention, {
{ code: '', filename: 'kebab-case.js' },
{ code: '', filename: 'index.js', options: [{ rule: 'PascalCase' }] },
{ code: '', filename: 'index.js', options: [{ rule: '[a-z]*' }] },
{ code: '', filename: '.eslintrc.js', options: [{ excepts: ['\..+'] }] },
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this line, I thought you might just want to remove the file from the target of rule/naming-convention.

If so, you can override the rules for the specific file in eslintrc.

module.exports = {
  ...
  overrides: [
    {
      files: ['.eslintrc.js'],
      plugins: ['filenames-simple'],
      rules: {
        'filenames-simple/naming-convention': 'off'
      }
    }
  ]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants