Skip to content

Using --path option ignores the root folder config file #105

Open

Description

@mgrebenets

Hi there

So I'm facing the issue which is actually very common for all other linters and formatters, such as SwiftLint and SwiftFormat.

I've created a file called .iblinter.yml in my project root folder, and I choose to ignore all storyboards in Example/Storyboards path.

excluded:
 - Example/Storyboards

This all works as expected if I just run iblinter in the root folder.

But, if I use --path option, e.g. iblinter --path Example, then IBLinter ignores my config file even if I run this command from the project root.

As I said, this is not something specific for IBLinter, SwiftFormat and SwiftLint have same behavior.
While I must say rubocop is different and respects config files from the project root.

With SwiftLint and SwiftFormat I was able to use -c / --config option and tell the tools that doesn't matter which paths I want to check, they still should use specific config file.

IBLinter is missing the -c / --config option though.

Could this option be added?

Then I would be able to run

iblinter --config $(pwd)/.iblinter.yml --path Example

and all my custom rules / exclude paths defined in the config will still apply

Activity

  1. phimage commented on May 30, 2019

    @phimage
    Member

    there is no "project root"
    there si current path, or paths given by options

    so yes adding --config is a good feature
    but the path in "excluded" must relative to this config file parent folder or the --path, that is the question!

  2. mgrebenets commented on May 30, 2019

    @mgrebenets
    Author

    I agree with the points, there's no such thing as root folder.

    I personally like rubocop behavior more, where exclude paths are relative to the location of the config file, and not to the location specified by --path option.

    Regardless, it would be nice to have --config option that behaves same way the SwiftLint's --config option behaves.

    I've changed the title to make this a feature request rather than issue with --path.

  3. phimage commented on Jun 3, 2019

    @phimage
    Member

    --config is now merged, but not released (need to fix the bug about watchkit before)

  4. phimage commented on Jun 3, 2019

    @phimage
    Member

    @mgrebenets could you test new option --config
    if you know how to compile (we use SPM)

    I am wondering how rules path must be managed, according to "--path" so the files must contains

    excluded:
     - Storyboards
    

    and not

    Example/Storyboards
    

    I think the best is to do like swiftlint...

  5. phimage commented on Jun 3, 2019

    @phimage
    Member

    I make some test with swiftlint on this project which defined - Sources

    $ swiftlint --path Sources/ --config $(pwd)/.swiftlint.yml 
    Loading configuration from '/Users/phimage/Dev/GitHub/IBLinter/.swiftlint.yml'
    Linting Swift files at paths Sources/
    No lintable files found at paths: 'Sources/'
    

    So he look files according to "--path" option, the working directory (so Sources/Sources and find nothing)

  6. mgrebenets commented on Jun 4, 2019

    @mgrebenets
    Author

    What I get with the tests is this:

    The storyboard I want to ignore is Apps/MyApp/WatchKitApp/Shared/Base.lproj/Interface.storyboard
    So I put this in my .iblinter.yml:

    excluded:
     - Apps/MyApp/WatchKitApp/Shared

    When running from the location of the config:

    # From location of .iblinter.yml
    iblinter --config $(pwd)/.iblinter.yml
    # or
    iblinter

    The file gets ignored as expected.

    When running like so:

    iblinter --config $(pwd)/.iblinter.yml --path Apps/MyApp/WatchKitApp/Shared

    the file is linted.

    I think this is how SwiftLint is behaving.

    Overall, the main reason I wanted to ignore storyboard is because it was crashing (#104). Now when there is no crash, it becomes less critical.

  7. phimage commented on Jun 4, 2019

    @phimage
    Member

    So we could do better than swiftlint by making an other option in command or in configuration file, to specify that file path are relative to configuration file, and not working directory
    But I have no time for this, if someone want to do it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions