SublimeJSCSFormatter icon indicating copy to clipboard operation
SublimeJSCSFormatter copied to clipboard

.sublime-project + config_path == 'Error: Configuration source ../developer/.jscsrc was not found.'

Open qikkeronline opened this issue 10 years ago • 12 comments

I've got a quick question regarding project specific settings; and then pointing to a project-dependand .jscsrc file.

I've got a structure like this:

- developer
- - gruntfile.js / .jscsrc / .sublime-project etc.

- webroot
- - website codebase

I'm trying to get SublimeJSCSFormatter to load a .jscsrc file from the .sublime-project (both resides in the same directory); but I can't get it to work. What I've tried so far (part of my .sublime-project file):

{
    "settings": {
        "JSCS-Formatter": {
            "config_path": "../developer/.jscsrc"
        }
    }   
}

and

{
    "settings": {
        "JSCS-Formatter": {
            "config_path": ".jscsrc"
        }
    }   
}

But both give me this error:

Error: Configuration source ../developer/.jscsrc was not found.

Thanks, and kind regards,

Gerben van Dijk, Qikker Online

qikkeronline avatar May 07 '15 10:05 qikkeronline

Can you use an absolute path instead of the relative one? Sublime's working directory may not be what you think it is. On May 7, 2015 6:07 AM, "Gerben van Dijk" [email protected] wrote:

I've got a quick question regarding project specific settings; and then pointing to a project-dependand .jscsrc file.

I've got a structure like this:

  • developer
    • gruntfile.js / .jscsrc / .sublime-project etc.
  • webroot
  • - website codebase

I'm trying to get SublimeJSCSFormatter to load a .jscsrc file from the .sublime-project (both resides in the same directory); but I can't get it to work. What I've tried so far (part of my .sublime-project file):

{ "settings": { "JSCS-Formatter": { "config_path": "../developer/.jscsrc" } } }

and

{ "settings": { "JSCS-Formatter": { "config_path": ".jscsrc" } } }

But both give me this error:

Error: Configuration source ../developer/.jscsrc was not found.

— Reply to this email directly or view it on GitHub https://github.com/TheSavior/SublimeJSCSFormatter/issues/30.

mrjoelkemp avatar May 07 '15 10:05 mrjoelkemp

Absolute path's do work; but I'd also like to be able to point to the file relative from the .sublime-project file. Else it doesn't make sense when we work with multiple developers - as they then need to manually change the path and I can't have the .sublime-project file in version control then.

Thanks for the quick reply :+1:

qikkeronline avatar May 07 '15 10:05 qikkeronline

With that setup, are devs only opening sublime text on the webroot folder? Or would they open it up on the parent directory that contains developer/ and webroot/?

mrjoelkemp avatar May 07 '15 11:05 mrjoelkemp

If it's the latter, can you try setting the config path to developer/.jscsrc?

mrjoelkemp avatar May 07 '15 11:05 mrjoelkemp

It is the latter - they would open it up in the parent directory. I've changed the absolute path to:

"config_path": "developer/.jscsrc"

and it still gives the same error.

For more clearity; check out this screenshot: http://i.imgur.com/mOes8EB.png

qikkeronline avatar May 07 '15 11:05 qikkeronline

Thanks for the screenshot. It would be more helpful to see the location of the sublime-settings file and the .jscsrc in the sidebar of the photo. The folder names look pretty long and I didn't see "developer" there, so I'm a little confused.

Can you try to specify your jscsrc file in the terminal using jscs -c developer/.jscsrc some_file or some variant to see what works. This is probably a quicker debugging cycle than modifying the plugin settings.

I'm still not convinced that this is an issue for the plugin to solve or if the setting value supplied is incorrect.

Thanks for sticking with the debugging of this issue.

On Thu, May 7, 2015 at 7:27 AM, Gerben van Dijk [email protected] wrote:

It is the latter - yhey would open it up in the parent directory. I've changed the absolute path to:

"config_path": "developer/.jscsrc"

and it still gives the same error.

For more clearity; check out this screenshot: http://i.imgur.com/mOes8EB.png

— Reply to this email directly or view it on GitHub https://github.com/TheSavior/SublimeJSCSFormatter/issues/30#issuecomment-99821469 .

mrjoelkemp avatar May 07 '15 11:05 mrjoelkemp

A new screenshot: http://i.imgur.com/HmCNLIP.png

In the sidebar I've defined custom folders (to save time traversing folders manually), and on the main screen you'll see the contents of my .sublime-project file (where I've added the SublimeJSCSFormatter options. In the project file you'll see the references to the folders in the sidebars as well.

I've had some issues with this before (i've been playing with ST3 plugin development myself lately) and I think that it's possible to get the directory where the .sublime-project file resides in; and then check if a .jscsrc file is there. Might be a friendly fallback for people like me :grinning:

qikkeronline avatar May 07 '15 12:05 qikkeronline

Thanks for the update. I'm reading up more about sublime-project files. In the mean time, do you think that the path having a trailing slash could cause a problem?

image

I notice that all other paths don't have a trailing slash. Worth a try; of course, you'd have to try your original, relative, config_path value.

mrjoelkemp avatar May 07 '15 17:05 mrjoelkemp

@mrjoelkemp thanks; I've tried it like this before, and I get the same error:

{
    "settings": {
        "JSCS-Formatter": {
            "config_path": "../developer/.jscsrc"
        }
    }   
}

qikkeronline avatar May 08 '15 06:05 qikkeronline

The argument for config_path gets passed directly to JSCS as an argument. So I believe the way JSCS handles it is that the path is relative to the file you are linting. I believe that means that you kind of have to use an absolute path.

It is possible that Sublime gives you some sort of thing like %PROJECT_ROOT% or something that would help you accomplish this although I don't really have any idea if that is the case.

elicwhite avatar May 08 '15 08:05 elicwhite

I'm going to try to take some time to look into it as well next week. Thanks again!

qikkeronline avatar May 08 '15 11:05 qikkeronline

@TheSavior found this in one of my old (broken) plugins; might be worth the try:

ROOT_PROJECT_DIR = os.path.dirname(sublime.active_window().project_file_name())

qikkeronline avatar May 25 '15 14:05 qikkeronline