Closed codemakerlive closed 8 years ago
Hi
Could you try installing postcss and stylelint as per the readme and let me know if that works for you?
npm install postcss stylelint
Thanks for the report.
I've removed and reinstalled, but I do a global install because of the dev machine (mac os x) setup: npm install -g postcss stylelint That should be ok right?
So we have in /usr/local/lib: postcss@5.0.1 stylelint@0.7.0
Still no linting in sublime on CSS files.
Hi - did you try running that without -g ?
On Fri, Aug 21, 2015 at 12:08 PM, codemakerlive notifications@github.com wrote:
I've removed and reinstalled, but I do a global install because of the dev machine setup: npm install -g postcss stylelint That should be ok right?
Still no linting in sublime on CSS files.
Reply to this email directly or view it on GitHub: https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/issues/2#issuecomment-133373924
Sorry to be a pain, but why? Node's globally installed, postcss is in my PATH, both postcss and stylelint are installed modules. Why necessitate local installation in addition?
Edit: I've tried now anyway - locally installed in my home folder, with .stylelintrc in there too Still no go.
I've got CSS3 sublime package (https://packagecontrol.io/packages/CSS3) installed, with CSS3 set as file syntax and Sublime's default CSS package disabled (as per CSS3 package instructions). Swapping that back and using Sublime's standard CSS package for file syntax didn't make a difference.
To confirm, you have a .stylelintrc
file in your project folder and you've run npm install postcss stylelint
?
Can you place SublimeLinter into debug mode (from the context menu) and provide any output from the sublime console related to the plugin?
Thanks
That's correct. I have that setup for a project, plus additional global install.
Sublime's console reveals:
SublimeLinter: stylelint: test.css ['/usr/local/bin/node', '/Users/<USER_NAME>/Library/Application Support/Sublime Text 3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js', '@', '--config', '/Users/<USER_NAME>/<PROJECT_PATH>/.stylelintrc']
SublimeLinter: stylelint output:
module.js:338
throw err;
^
Error: Cannot find module 'postcss'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/<USER_NAME>/Library/Application Support/Sublime Text 3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js:3:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
So it can't find postcss yet it is in my PATH
I'm in the same boat... A couple of things via https://github.com/code42day/postcss-cli/issues/16
• If PostCSS cannot find the stylelint
plugin it throws that module.js:338
error
• If PostCSS is installed globally, Stylelint should also be installed globally.
Following Sublime Linter instructions https://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#finding-a-linter-executable
which postcss
returns nothing
which stylelint
returns nothing
Now this brings me back to postcss-cli
, is this what we need for this Stylelint Sublime plugin?
If I install postcss-cli
via npm install postcss-cli -g
(I also have PostCSS installed globally)
which postcss
returns /usr/local/bin/postcss
Now I can execute postcss
from the terminal and get:
Usage: /usr/local/bin/postcss -use|-p plugin [--config|-c config.json] [--output|-o output.css] [input.css]
Options:
-c, --config JSON file with plugin configuration
-u, --use postcss plugin name (can be used multiple times)
-o, --output Output file (stdout if not provided)
-d, --dir Output directory
-w, --watch auto-recompile when detecting source changes
--safe Enable postcss safe mode. [boolean]
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
Examples:
postcss --use autoprefixer -c options. Use autoprefixer as a postcss plugin
json -o screen.css screen.css
postcss --use autoprefixer -- Pass plugin parameters in plugin.
autoprefixer.browsers "> 5%" -o screen. option notation
css screen.css
postcss -u postcss-cachify -u Use multiple plugins and multiple
autoprefixer -d build *.css input files
Please specify at least one plugin name.
It also looks like postcss-reporter
is required based on https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/blob/master/stylelint_wrapper.js
Thanks for the info.
To clear up a couple of things
postcss-cli
is not needed, the plugin has its own wrapper.post-css-reporter
is not needed. It uses a custom reporter. The issue isn't the linter being unable to find the executable, it's node that's unable to find the modules.
There seems to be an issue with the node script finding modules that are installed globally. I've found if I install like so - cd ~/ && npm install posts stylelint
it will work. I will continue looking at why global modules can't be found though.
I have the postcss-cli, hence why I find it in my PATH - sorry forgot to mention.
As the plugin has it's own wrapper to initiate post css you could do the following to cover methods (at the cost of using 1 additional, but very useful module, shelljs):
Note; If either steps 1 or 2 work, store the correct invocation name (path or "postcss" cmd) in a string so you've only checked once, then shelljs.exec()'d each time you invoke postcss, passing that string. Set a flag do_use_cli boolean to check on each invocation of postcss to check whether to use shelljs or your require implementation.
I've updated the custom wrapper to start looking for your local installs of postcss & stylelint from the directory your .stylelintrc
is located. So it shouldn't be necessary to have separate installs of either to get this plugin to work. Let me know if you get any issues with this. Cheers
Fixed in 1.0.2
Hi, sorry but can global installs be facilitated in order to resolve the issue? Most other linter plug-ins with SublimeLinter work under global install, which would be a common setup on a dev machine with multiple users.
Also, this plugin's readme states:
In order for stylelint to be executed by SublimeLinter, you must ensure that nodejs is available
to SublimeLinter. Before going any further, please read and follow the steps in “Finding a
linter executable” through “Validating your PATH” in the documentation.
Once you have installed and configured stylelint, you can proceed to install the
SublimeLinter-contrib-stylelint plugin if it is not yet installed.
This is not the case (correct instruction) in this instance, unless the user has postcss-cli installed.
I'm running with global install and postcss-cli and hoping we can get this linter plugin facilitating that setup.
The plugin executes nodejs directly, so the readme is accurate. It then invokes stylelint via requiring the node module. Because of this, a global install isn't possible unless you locally install the module in a shared path. A custom reporter is needed for the linter to be able to parse the output from stylelint properly.
The solution, as part of the last release, was to use the node module you have installed in your project directory. So say for example your .stylelintrc
file lives in /Users/you/code_prj/.stylelintrc
, the plugin would first check /Users/you/code_prj/node_modules/
for the existence of stylelint.
Postcss-cli is neither required or supported.
Hope this helps, thanks.
Following the instructions I installed postcss
and stylelint
locally in a project.
No .stylelintrc file is created.
When enabling debug mode of SublimeLinter, I get this error messages in the console:
SublimeLinter: stylelint: styles2.css ['/usr/local/bin/node', '/home/*****/.config/sublime-text-3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js', '@']
SublimeLinter: stylelint output:
module.js:338
throw err;
^
Error: Cannot find module 'postcss'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/****/.config/sublime-text-3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js:21:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
Ideas?
Hi. You must create the .stylelintrc file yourself. Thanks.
On Thu, Sep 3, 2015 at 12:18 PM, Artiom Neganov notifications@github.com wrote:
Following the instructions I installed
postcss
andstylelint
locally in a project. No .stylelintrc file is created. When enabling debug mode of SublimeLinter, I get this error messages in the console:ublimeLinter: stylelint: styles2.css ['/usr/local/bin/node', '/home/*****/.config/sublime-text-3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js', '@'] SublimeLinter: stylelint output: module.js:338 throw err; ^ Error: Cannot find module 'postcss' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:278:25) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/home/****/.config/sublime-text-3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js:21:15) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10)
Ideas?
Reply to this email directly or view it on GitHub: https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/issues/2#issuecomment-137410948
@kungfusheep
Erm... wow. Can't it just follow the widely adopted practice to use a default one? Honesty I don't feel like I have time and desire to learn one more language right now which is Rules languages. I think I will be satisfied with some... common rules.
Also I don't quite understand what is supposed to be a home/current directory for the plugin: if I have 3 directories in a sublime project then how it will resolve? Or... that rc file is exactly what gives the plugin the idea about "the current" path?
P.S. @codemakerlive sorry for mentioning you, it was a typo
@kungfusheep ops, the previous was for you
Well, I have one more issue now when I created (yet empty) .stylelintrc
.
SublimeLinter: stylelint output:
undefined:0
SyntaxError: Unexpected end of input
at Object.parse (native)
at Object.<anonymous> (/home/*****/.config/sublime-text-3/Packages/SublimeLinter-contrib-stylelint/stylelint_wrapper.js:11:19)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Stylelint pitches itself as an unopinionated linter, so it would be wrong of me to provide my own opinion of what a default rule set should be.
After you've created the .stylelintrc file, if you don't provide a rule set then stylelint will not perform any linting. See the stylelint GitHub page for information on using rules.
On Thu, Sep 3, 2015 at 12:31 PM, Artiom Neganov notifications@github.com wrote:
@kungfusheep ops, the previous was for you
Reply to this email directly or view it on GitHub: https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/issues/2#issuecomment-137412693
Well, while in theory you are probably right, don't you think it must not be so boring? There are too many thing in the world to spend on each that much time, especially when we mean... just a tool, like a hammer. Do you suggest to read hammer instructions?
Really, when you install something it just works out of the box. This is perhaps not so for some server software, but you don't expect much headache before using hammers.
The fact is: the plugins doesn't work out of the box at all. Even following instructions doesn't help and only after enabling Debug mode from the patron package (which is SublimeLinter) we become aware of javascript errors in the console.
I'm not sure what the issue is here. The readme states that you must install nodejs, install stylelint locally, create an rc file (and mentions that the location is significant) and even provides a default configuration example.
If the issue is with stylelints choice to not be opinionated then I'm sure the guys over at stylelint would be interested in hearing your opinion. Cheers.
On Thu, Sep 3, 2015 at 12:51 PM, Artiom Neganov notifications@github.com wrote:
Well, while in theory you are probably right, don't you think it must not be so boring? There are too many thing in the world to spend on each that much time, especially when we mean... just a tool, like a hammer. Do you suggest to read hammer instructions? Really, when you install something it just works out of the box. This is perhaps not so for some server software, but you don't expect much headache before using hammers.
The fact is: the plugins doesn't work out of the box at all. Even following instructions doesn't help and only after enabling Debug mode from the patron package (which is SublimeLinter) we become aware of javascript errors in the console.
Reply to this email directly or view it on GitHub: https://github.com/kungfusheep/SublimeLinter-contrib-stylelint/issues/2#issuecomment-137415531
Does this plugin require a separate local install of stylelint for every project I would like to use it with? Doesn't appear to work with global install. Thanks.
What is the state of this project at the moment? I know it is early days.
I have a working .stylelintrc file for rule configuration. I can run postcss with stylelint plugin and identical rule config in a post css config json, running direct through the cmd-line and successfully linting css.
I have postcss in my PATH, but not stylelint. I presume this is correct setup despite your readme mentioning to make stylelint locatable in PATH (as per standard SublimeLinter plugin documentation), however as you know, stylelint runs as postcss plugin and installs with no binary file.
So I think I'm setup correctly, yet linting in sublime does nothing at the moment for CSS with your plugin enabled.