Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly set the errored property for --report options #5079

Merged
merged 4 commits into from Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/prepareReturnValue.js
Expand Up @@ -34,7 +34,10 @@ function prepareReturnValue(stylelintResults, options, formatter) {
if (reportDescriptionlessDisables) descriptionlessDisables(stylelintResults);

const errored = stylelintResults.some(
(result) => result.errored || result.parseErrors.length > 0,
(result) =>
result.errored ||
result.parseErrors.length > 0 ||
result.warnings.some((warning) => warning.severity === 'error'),
);

/** @type {StylelintStandaloneReturnValue} */
Expand Down
69 changes: 69 additions & 0 deletions system-tests/004/__snapshots__/fs.test.js.snap
@@ -0,0 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`no-fs - errored state for reportNeedlessDisables 1`] = `
Object {
"errored": true,
"output": Array [
Object {
"deprecations": Array [],
"errored": false,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [
Object {
"column": 1,
"line": 1,
"rule": "--report-needless-disables",
"severity": "error",
"text": "Needless disable for \\"block-no-empty\\"",
},
],
},
],
"reportedDisables": Array [],
"results": Array [
Object {
"deprecations": Array [],
"errored": false,
"ignored": undefined,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [
Object {
"column": 1,
"line": 1,
"rule": "--report-needless-disables",
"severity": "error",
"text": "Needless disable for \\"block-no-empty\\"",
},
],
},
],
}
`;

exports[`no-fs - no errored state 1`] = `
Object {
"errored": false,
"output": Array [
Object {
"deprecations": Array [],
"errored": false,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [],
},
],
"reportedDisables": Array [],
"results": Array [
Object {
"deprecations": Array [],
"errored": false,
"ignored": undefined,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [],
},
],
}
`;
69 changes: 69 additions & 0 deletions system-tests/004/__snapshots__/no-fs.test.js.snap
@@ -0,0 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`no-fs - errored state for reportNeedlessDisables 1`] = `
Object {
"errored": true,
"output": Array [
Object {
"deprecations": Array [],
"errored": false,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [
Object {
"column": 1,
"line": 1,
"rule": "--report-needless-disables",
"severity": "error",
"text": "Needless disable for \\"block-no-empty\\"",
},
],
},
],
"reportedDisables": Array [],
"results": Array [
Object {
"deprecations": Array [],
"errored": false,
"ignored": undefined,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [
Object {
"column": 1,
"line": 1,
"rule": "--report-needless-disables",
"severity": "error",
"text": "Needless disable for \\"block-no-empty\\"",
},
],
},
],
}
`;

exports[`no-fs - no errored state 1`] = `
Object {
"errored": false,
"output": Array [
Object {
"deprecations": Array [],
"errored": false,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [],
},
],
"reportedDisables": Array [],
"results": Array [
Object {
"deprecations": Array [],
"errored": false,
"ignored": undefined,
"invalidOptionWarnings": Array [],
"parseErrors": Array [],
"warnings": Array [],
},
],
}
`;
5 changes: 5 additions & 0 deletions system-tests/004/config.json
@@ -0,0 +1,5 @@
{
"rules": {
"block-no-empty": true
}
}
29 changes: 29 additions & 0 deletions system-tests/004/fs.test.js
@@ -0,0 +1,29 @@
'use strict';

const stylelint = require('../../lib');
const { caseConfigFile, caseFilesForFix, prepForSnapshot } = require('../systemTestUtils');

const CASE_NUMBER = '004';

it('no-fs - errored state for reportNeedlessDisables', async () => {
vankop marked this conversation as resolved.
Show resolved Hide resolved
expect(
prepForSnapshot(
await stylelint.lint({
files: await caseFilesForFix(CASE_NUMBER),
configFile: caseConfigFile(CASE_NUMBER),
reportNeedlessDisables: true,
}),
),
).toMatchSnapshot();
}, 10000);

it('no-fs - no errored state', async () => {
expect(
prepForSnapshot(
await stylelint.lint({
files: await caseFilesForFix(CASE_NUMBER),
configFile: caseConfigFile(CASE_NUMBER),
}),
),
).toMatchSnapshot();
}, 10000);
29 changes: 29 additions & 0 deletions system-tests/004/no-fs.test.js
@@ -0,0 +1,29 @@
'use strict';

const stylelint = require('../../lib');
const { caseConfig, caseCode, prepForSnapshot } = require('../systemTestUtils');

const CASE_NUMBER = '004';

it('no-fs - errored state for reportNeedlessDisables', async () => {
expect(
prepForSnapshot(
await stylelint.lint({
code: await caseCode(CASE_NUMBER),
config: await caseConfig(CASE_NUMBER),
reportNeedlessDisables: true,
}),
),
).toMatchSnapshot();
}, 10000);

it('no-fs - no errored state', async () => {
expect(
prepForSnapshot(
await stylelint.lint({
code: await caseCode(CASE_NUMBER),
config: await caseConfig(CASE_NUMBER),
}),
),
).toMatchSnapshot();
}, 10000);
4 changes: 4 additions & 0 deletions system-tests/004/stylesheet.css
@@ -0,0 +1,4 @@
/* stylelint-disable block-no-empty */
a {
color: red;
}