Adding --no-color flag to stylelint args (#5050)

* Adding --no-color flag to sass stylelint

* Adding --no-color to all stylelint args

* Adding --no-color expectation to stylelint tests

* Properly handling SyntaxError for stylelint; adding corresponding test

* Fixing CSS stylelint parameters and adding regression test
This commit is contained in:
Steve Matney
2025-11-22 05:00:41 -07:00
committed by GitHub
parent b9d7f56471
commit de2d3da738
16 changed files with 79 additions and 23 deletions

View File

@@ -0,0 +1,33 @@
Before:
call ale#assert#SetUpLinterTest('css', 'stylelint')
unlet! b:executable
After:
unlet! b:executable
call ale#assert#TearDownLinterTest()
Execute(node_modules directories should be discovered):
call ale#test#SetFilename('../test-files/stylelint/nested/testfile.css')
let b:executable = ale#path#Simplify(
\ g:dir
\ . '/../test-files/stylelint/node_modules/.bin/stylelint'
\)
AssertLinter b:executable, ale#Escape(b:executable) . ' --no-color --stdin-filename %s'
Execute(The global override should work):
let b:ale_css_stylelint_executable = 'foobar'
let b:ale_css_stylelint_use_global = 1
call ale#test#SetFilename('../test-files/stylelint/nested/testfile.css')
AssertLinter 'foobar', ale#Escape('foobar') . ' --no-color --stdin-filename %s'
Execute(Extra options should be configurable):
call ale#test#SetFilename('../test-files/dummy')
let b:ale_css_stylelint_options = '--configFile ''/absolute/path/to/file'''
AssertLinter 'stylelint',
\ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --no-color --stdin-filename %s'

View File

@@ -37,7 +37,7 @@ Execute(node_modules directories should be discovered):
AssertEqual b:executable, ale_linters#html#stylelint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape(b:executable) . ' --stdin-filename %s',
\ ale#Escape(b:executable) . ' --no-color --stdin-filename %s',
\ ale_linters#html#stylelint#GetCommand(bufnr(''))
Execute(The global override should work):
@@ -48,7 +48,7 @@ Execute(The global override should work):
AssertEqual 'foobar', ale_linters#html#stylelint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('foobar') . ' --stdin-filename %s',
\ ale#Escape('foobar') . ' --no-color --stdin-filename %s',
\ ale_linters#html#stylelint#GetCommand(bufnr(''))
Execute(Extra options should be configurable):
@@ -56,5 +56,5 @@ Execute(Extra options should be configurable):
AssertEqual 'stylelint', ale_linters#html#stylelint#GetExecutable(bufnr(''))
AssertEqual
\ ale#Escape('stylelint') . ' --whatever --stdin-filename %s',
\ ale#Escape('stylelint') . ' --whatever --no-color --stdin-filename %s',
\ ale_linters#html#stylelint#GetCommand(bufnr(''))

View File

@@ -14,7 +14,7 @@ Execute(node_modules directories should be discovered):
\ . '/../test-files/stylelint/node_modules/.bin/stylelint'
\)
AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s'
AssertLinter b:executable, ale#Escape(b:executable) . ' --no-color --stdin-filename %s'
Execute(The global override should work):
let b:ale_less_stylelint_executable = 'foobar'
@@ -22,11 +22,11 @@ Execute(The global override should work):
call ale#test#SetFilename('../test-files/stylelint/nested/testfile.less')
AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s'
AssertLinter 'foobar', ale#Escape('foobar') . ' --no-color --stdin-filename %s'
Execute(Extra options should be configurable):
let b:ale_less_stylelint_options = '--whatever'
call ale#test#SetFilename('../test-files/dummy')
AssertLinter 'stylelint',
\ ale#Escape('stylelint') . ' --whatever --stdin-filename %s'
\ ale#Escape('stylelint') . ' --whatever --no-color --stdin-filename %s'

View File

@@ -14,7 +14,7 @@ Execute(node_modules directories should be discovered):
\ . '/../test-files/stylelint/node_modules/.bin/stylelint'
\)
AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s'
AssertLinter b:executable, ale#Escape(b:executable) . ' --no-color --stdin-filename %s'
Execute(The global override should work):
let b:ale_scss_stylelint_executable = 'foobar'
@@ -22,7 +22,7 @@ Execute(The global override should work):
call ale#test#SetFilename('../test-files/stylelint/nested/testfile.scss')
AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s'
AssertLinter 'foobar', ale#Escape('foobar') . ' --no-color --stdin-filename %s'
Execute(Extra options should be configurable):
call ale#test#SetFilename('../test-files/dummy')
@@ -30,4 +30,4 @@ Execute(Extra options should be configurable):
let b:ale_scss_stylelint_options = '--configFile ''/absolute/path/to/file'''
AssertLinter 'stylelint',
\ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --stdin-filename %s'
\ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --no-color --stdin-filename %s'

View File

@@ -14,7 +14,7 @@ Execute(node_modules directories should be discovered):
\ . '/../test-files/stylelint/node_modules/.bin/stylelint'
\)
AssertLinter b:executable, ale#Escape(b:executable) . ' --syntax=sugarss --stdin-filename %s'
AssertLinter b:executable, ale#Escape(b:executable) . ' --syntax=sugarss --no-color --stdin-filename %s'
Execute(The global override should work):
let b:ale_sugarss_stylelint_executable = 'foobar'
@@ -22,7 +22,7 @@ Execute(The global override should work):
call ale#test#SetFilename('../test-files/stylelint/nested/testfile.sss')
AssertLinter 'foobar', ale#Escape('foobar') . ' --syntax=sugarss --stdin-filename %s'
AssertLinter 'foobar', ale#Escape('foobar') . ' --syntax=sugarss --no-color --stdin-filename %s'
Execute(Extra options should be configurable):
call ale#test#SetFilename('../test-files/dummy')
@@ -30,4 +30,4 @@ 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'
\ ale#Escape('stylelint') . ' --configFile ''/absolute/path/to/file'' --syntax=sugarss --no-color --stdin-filename %s'