diff --git a/lib/__tests__/standalone-fix.test.js b/lib/__tests__/standalone-fix.test.js index 698af9180c..7a6c2219f8 100644 --- a/lib/__tests__/standalone-fix.test.js +++ b/lib/__tests__/standalone-fix.test.js @@ -246,7 +246,8 @@ it('one rule being disabled', async () => { fix: true, }); - expect(JSON.parse(result.output)[0].errored).toBe(true); + expect(result.results[0].errored).toBe(true); + expect(result.output).toBe('\n a {\n color: red;\n }'); }); it('two rules being disabled', async () => { @@ -276,7 +277,7 @@ it('two rules being disabled', async () => { fix: true, }); - const warnings = JSON.parse(result.output)[0].warnings; + const warnings = result.results[0].warnings; expect(warnings.some((w) => w.text === 'Expected indentation of 0 spaces (indentation)')).toBe( true, @@ -284,6 +285,7 @@ it('two rules being disabled', async () => { expect(warnings.some((w) => w.text === 'Expected "COLOR" to be "color" (property-case)')).toBe( true, ); + expect(result.output).toBe('\n a {\n COLOR: red;\n }'); }); it('one rule being disabled and another still autofixing', async () => { @@ -296,24 +298,25 @@ it('one rule being disabled and another still autofixing', async () => { code, config: { rules: { - indentation: [ - 2, + indentation: [0], + 'property-case': [ + 'lower', { disableFix: true, }, ], - 'property-case': ['lower'], }, }, fix: true, }); - const warnings = JSON.parse(result.output)[0].warnings; + const warnings = result.results[0].warnings; expect(warnings.some((w) => w.text === 'Expected indentation of 0 spaces (indentation)')).toBe( - true, + false, ); expect(warnings.some((w) => w.text === 'Expected "COLOR" to be "color" (property-case)')).toBe( - false, + true, ); + expect(result.output).toBe('\na {\nCOLOR: red;\n}'); }); diff --git a/lib/lintPostcssResult.js b/lib/lintPostcssResult.js index 9e09c74b00..7f9421e5bf 100644 --- a/lib/lintPostcssResult.js +++ b/lib/lintPostcssResult.js @@ -91,10 +91,6 @@ function lintPostcssResult(stylelintOptions, postcssResult, config) { // disableFix in secondary option const disableFix = (secondaryOptions && secondaryOptions.disableFix === true) || false; - if (disableFix) { - postcssResult.stylelint.ruleDisableFix = true; - } - postcssResult.stylelint.ruleSeverities[ruleName] = (secondaryOptions && secondaryOptions.severity) || defaultSeverity; postcssResult.stylelint.customMessages[ruleName] = secondaryOptions && secondaryOptions.message; diff --git a/lib/standalone.js b/lib/standalone.js index 1848dae2a7..d78b165c9a 100644 --- a/lib/standalone.js +++ b/lib/standalone.js @@ -139,12 +139,7 @@ async function standalone({ const postcssResult = stylelintResult._postcssResult; const returnValue = prepareReturnValue([stylelintResult], maxWarnings, formatterFunction, cwd); - if ( - fix && - postcssResult && - !postcssResult.stylelint.ignored && - !postcssResult.stylelint.ruleDisableFix - ) { + if (fix && postcssResult && !postcssResult.stylelint.ignored) { returnValue.output = !postcssResult.stylelint.disableWritingFix && postcssResult.opts ? // If we're fixing, the output should be the fixed code diff --git a/types/stylelint/index.d.ts b/types/stylelint/index.d.ts index a2d7f0e87f..5adc554d31 100644 --- a/types/stylelint/index.d.ts +++ b/types/stylelint/index.d.ts @@ -110,7 +110,6 @@ declare module 'stylelint' { stylelintWarning?: boolean; disableWritingFix?: boolean; config?: Config; - ruleDisableFix?: boolean; }; type EmptyResult = {