Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Not linting header files #25

Open
maasha opened this issue Nov 11, 2015 · 5 comments
Open

Not linting header files #25

maasha opened this issue Nov 11, 2015 · 5 comments

Comments

@maasha
Copy link

maasha commented Nov 11, 2015

It used to work at some point, but after reinstalling Atom and upgrading linter etc, header files are not linted. My header files have .h suffix, and I didn't touch the default extensions.

Atom 1.1.0
linter 1.10.0
linter-cpplint 1.0.0

@Arcanemagus
Copy link
Member

Looks like the grammarScopes need to be expanded to include the scope header files identify as, a PR would be welcome!

@JayThomason
Copy link

I looked into this because I seemed to be having the same problem. It turns out that atom is detecting C++ header files as C headers (see atom/atom#4156).

The easiest fix for me was forcing atom to recognize .h files as C++ instead of C by adding to ~/.atom/config.cson

  core:
    customFileTypes:
      "source.cpp": [
        "h"
      ]

This could also be fixed by adding "source.c" to the grammarScopes, however considering that the problem is not caused by linter-cpplint I don't like that solution. The above solution will also give proper C++ syntax highlighting, etc.

@Arcanemagus
Copy link
Member

C++ style header files should actually have a .hpp extension, .h files are C header files. That being said, a lot of projects name them improperly so the choices are either overriding the scope for .h files like you mention, or marking this package as supporting source.c, which can lead to other issues as it would then try to lint C code...

@JayThomason
Copy link

I agree that it would be nice if C++ header files used the .hpp extension but, as you said, many projects use .h files for C++ headers. For example even the Google C++ style guide advocates usage of .h for C++ header files.

While not optimal, the reason that I suggested the workaround above is because this problem should be fixed by whatever system is detecting the file type, instead of plugins which rely on that functionality.

The other workaround is to change the file type in atom on a file by file basis using the grammar selector.

@keplersj
Copy link
Contributor

@Arcanemagus This could be fixed by making the C syntax valid on this linter, and checking that the file being linted ends with a header extension.

Or we could convince the core Atom team to distinguish C source files from C header files...

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

No branches or pull requests

4 participants