diff --git a/README.md b/README.md index c0beebe6..62c6d68f 100644 --- a/README.md +++ b/README.md @@ -185,13 +185,14 @@ formatting. | RPM spec | [rpmlint](https://github.com/rpm-software-management/rpmlint) (disabled by default; see `:help ale-integration-spec`) | | Ruby | [brakeman](http://brakemanscanner.org/) !!, [rails_best_practices](https://github.com/flyerhzm/rails_best_practices) !!, [reek](https://github.com/troessner/reek), [rubocop](https://github.com/bbatsov/rubocop), [ruby](https://www.ruby-lang.org), [rufo](https://github.com/ruby-formatter/rufo), [solargraph](https://solargraph.org), [standardrb](https://github.com/testdouble/standard) | | Rust | [cargo](https://github.com/rust-lang/cargo) !! (see `:help ale-integration-rust` for configuration instructions), [rls](https://github.com/rust-lang-nursery/rls), [rustc](https://www.rust-lang.org/), [rustfmt](https://github.com/rust-lang-nursery/rustfmt) | -| SASS | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) | +| Sass | [sass-lint](https://www.npmjs.com/package/sass-lint), [stylelint](https://github.com/stylelint/stylelint) | | SCSS | [prettier](https://github.com/prettier/prettier), [sass-lint](https://www.npmjs.com/package/sass-lint), [scss-lint](https://github.com/brigade/scss-lint), [stylelint](https://github.com/stylelint/stylelint) | | Scala | [fsc](https://www.scala-lang.org/old/sites/default/files/linuxsoft_archives/docu/files/tools/fsc.html), [sbtserver](https://www.scala-sbt.org/1.x/docs/sbt-server.html), [scalac](http://scala-lang.org), [scalafmt](https://scalameta.org/scalafmt/), [scalastyle](http://www.scalastyle.org)| | Slim | [slim-lint](https://github.com/sds/slim-lint) | | SML | [smlnj](http://www.smlnj.org/) | | Solidity | [solhint](https://github.com/protofire/solhint), [solium](https://github.com/duaraghav8/Solium) | | Stylus | [stylelint](https://github.com/stylelint/stylelint) | +| SugarSS | [stylelint](https://github.com/stylelint/stylelint) | | SQL | [sqlint](https://github.com/purcell/sqlint), [sqlfmt](https://github.com/jackc/sqlfmt) | | Swift | [swiftlint](https://github.com/realm/SwiftLint), [swiftformat](https://github.com/nicklockwood/SwiftFormat) | | Tcl | [nagelfar](http://nagelfar.sourceforge.net) !! | diff --git a/ale_linters/sugarss/stylelint.vim b/ale_linters/sugarss/stylelint.vim new file mode 100644 index 00000000..6b0adf5a --- /dev/null +++ b/ale_linters/sugarss/stylelint.vim @@ -0,0 +1,21 @@ +" Author: toastal +" Description: `stylelint` linter for SugarSS files + +call ale#Set('sugarss_stylelint_executable', 'stylelint') +call ale#Set('sugarss_stylelint_options', '') +call ale#Set('sugarss_stylelint_use_global', get(g:, 'ale_use_global_executables', 0)) + +function! ale_linters#sugarss#stylelint#GetCommand(buffer) abort + return '%e ' . ale#Pad(ale#Var(a:buffer, 'sugarss_stylelint_options')) + \ . ' --syntax=sugarss' + \ . ' --stdin-filename %s' +endfunction + +call ale#linter#Define('sugarss', { +\ 'name': 'stylelint', +\ 'executable_callback': ale#node#FindExecutableFunc('sugarss_stylelint', [ +\ 'node_modules/.bin/stylelint', +\ ]), +\ 'command_callback': 'ale_linters#sugarss#stylelint#GetCommand', +\ 'callback': 'ale#handlers#css#HandleStyleLintFormat', +\}) diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index a7422f22..98a35b7e 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -122,7 +122,7 @@ let s:default_registry = { \ }, \ 'stylelint': { \ 'function': 'ale#fixers#stylelint#Fix', -\ 'suggested_filetypes': ['css', 'sass', 'scss', 'stylus'], +\ 'suggested_filetypes': ['css', 'sass', 'scss', 'sugarss', 'stylus'], \ 'description': 'Fix stylesheet files using stylelint --fix.', \ }, \ 'swiftformat': { diff --git a/doc/ale-sass.txt b/doc/ale-sass.txt index 735f44b2..22d7c472 100644 --- a/doc/ale-sass.txt +++ b/doc/ale-sass.txt @@ -1,5 +1,5 @@ =============================================================================== -ALE SASS Integration *ale-sass-options* +ALE Sass Integration *ale-sass-options* =============================================================================== diff --git a/doc/ale-sugarss.txt b/doc/ale-sugarss.txt new file mode 100644 index 00000000..8e991e54 --- /dev/null +++ b/doc/ale-sugarss.txt @@ -0,0 +1,31 @@ +=============================================================================== +ALE SugarSS Integration *ale-sugarss-options* + + +=============================================================================== +stylelint *ale-sugarss-stylelint* + +g:ale_sugarss_stylelint_executable *g:ale_sugarss_stylelint_executable* + *b:ale_sugarss_stylelint_executable* + Type: |String| + Default: `'stylelint'` + + See |ale-integrations-local-executables| + +g:ale_sugarss_stylelint_options *g:ale_sugarss_stylelint_options* + *b:ale_sugarss_stylelint_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to stylelint. + +g:ale_sugarss_stylelint_use_global *g:ale_sugarss_stylelint_use_global* + *b:ale_sugarss_stylelint_use_global* + Type: |String| + Default: `get(g:, 'ale_use_global_executables', 0)` + + See |ale-integrations-local-executables| + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index 860280e2..9b91d3a0 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -324,6 +324,8 @@ CONTENTS *ale-contents* sqlfmt..............................|ale-sql-sqlfmt| stylus................................|ale-stylus-options| stylelint...........................|ale-stylus-stylelint| + sugarss...............................|ale-sugarss-options| + stylelint...........................|ale-sugarss-stylelint| tcl...................................|ale-tcl-options| nagelfar............................|ale-tcl-nagelfar| terraform.............................|ale-terraform-options| @@ -502,13 +504,14 @@ Notes: * RPM spec: `rpmlint` * Ruby: `brakeman`, `rails_best_practices`!!, `reek`, `rubocop`, `ruby`, `rufo`, `solargraph`, `standardrb` * Rust: `cargo`!!, `rls`, `rustc` (see |ale-integration-rust|), `rustfmt` -* SASS: `sass-lint`, `stylelint` +* Sass: `sass-lint`, `stylelint` * SCSS: `prettier`, `sass-lint`, `scss-lint`, `stylelint` * Scala: `fsc`, `sbtserver`, `scalac`, `scalafmt`, `scalastyle` * Slim: `slim-lint` * SML: `smlnj` * Solidity: `solhint`, `solium` * Stylus: `stylelint` +* SugarSS: `stylelint` * SQL: `sqlint`, `sqlfmt` * Swift: `swiftlint`, `swiftformat` * Tcl: `nagelfar`!! @@ -2785,7 +2788,7 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()* and have been checked at least once. Temporary files in directories used for Vim - temporary files with `tempname()` will be asssumed + temporary files with `tempname()` will be assumed to be the buffer being checked, unless the `bufnr` key is also set with a valid number for some other buffer. diff --git a/test/command_callback/test_sugarss_stylelint_command_callback.vader b/test/command_callback/test_sugarss_stylelint_command_callback.vader new file mode 100644 index 00000000..448436fb --- /dev/null +++ b/test/command_callback/test_sugarss_stylelint_command_callback.vader @@ -0,0 +1,31 @@ +Before: + call ale#assert#SetUpLinterTest('sugarss', 'stylelint') + unlet! b:executable + +After: + unlet! b:executable + call ale#assert#TearDownLinterTest() + +Execute(node_modules directories should be discovered): + call ale#test#SetFilename('stylelint_paths/nested/testfile.sss') + + let b:executable = ale#path#Simplify( + \ g:dir + \ . '/stylelint_paths/node_modules/.bin/stylelint' + \) + + AssertLinter b:executable, ale#Escape(b:executable) . ' --syntax=sugarss --stdin-filename %s' + +Execute(The global override should work): + let b:ale_sugarss_stylelint_executable = 'foobar' + let b:ale_sugarss_stylelint_use_global = 1 + + call ale#test#SetFilename('stylelint_paths/nested/testfile.sss') + + AssertLinter 'foobar', ale#Escape('foobar') . ' --syntax=sugarss --stdin-filename %s' + +Execute(Extra options should be configurable): + let b:ale_sugarss_stylelint_options = '--configFile ''/absolute/path/to/file''' + + AssertLinter 'stylelint', + \ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --syntax=sugarss --stdin-filename %s'