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

Deprecate createRuleTester API #4265

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

const checkAgainstRule = require("./utils/checkAgainstRule");
const createPlugin = require("./createPlugin");
const createRuleTester = require("./testUtils/createRuleTester");
const createStylelint = require("./createStylelint");
const formatters = require("./formatters");
const postcssPlugin = require("./postcssPlugin");
Expand Down Expand Up @@ -32,7 +31,6 @@ api.lint = standalone;
api.rules = requiredRules;
api.formatters = formatters;
api.createPlugin = createPlugin;
api.createRuleTester = createRuleTester;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to put this back, as we discussed in #4267. We'll only deprecate this API in the following release.

api.createLinter = createStylelint;

module.exports = api;
10 changes: 8 additions & 2 deletions lib/testUtils/createRuleTester.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const postcss = require("postcss");
const sassSyntax = require("postcss-sass");
const scssSyntax = require("postcss-scss");
const sugarss = require("sugarss");
const { deprecate } = require("util");

/**
* Create a stylelint rule testing function.
Expand Down Expand Up @@ -97,7 +98,7 @@ function checkCaseForOnly(caseType, testCase) {
onlyTest = { case: testCase, type: caseType };
}

module.exports = function(equalityCheck) {
function createRuleTester(equalityCheck) {
return function(rule, schema) {
const alreadyHadOnlyTest = !!onlyTest;

Expand All @@ -122,7 +123,7 @@ module.exports = function(equalityCheck) {
});
}
};
};
}

function processGroup(rule, schema, equalityCheck) {
const ruleName = schema.ruleName;
Expand Down Expand Up @@ -305,3 +306,8 @@ function processGroup(rule, schema, equalityCheck) {
function spaceJoin() {
return _.compact(Array.from(arguments)).join(" ");
}

module.exports = deprecate(
createRuleTester,
"createRuleTester deprecated, please use https://github.com/stylelint/jest-preset-stylelint instead"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"createRuleTester deprecated, please use https://github.com/stylelint/jest-preset-stylelint instead"
"createRuleTester deprecated. See https://github.com/stylelint/stylelint/issues/4267"

jest-preset-stylelint is not ready to be used. So it's better to point to discussion instead.

);