Skip to content

Commit

Permalink
Copy validateTypes.js from Stylelint
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR committed Mar 23, 2023
1 parent 6aadf58 commit afa67c3
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/rules/at-else-closing-brace-newline-after/index.js
@@ -1,6 +1,6 @@
import { namespace, ruleUrl } from "../../utils";
import { utils } from "stylelint";
import { isBoolean } from "stylelint/lib/utils/validateTypes";
import { isBoolean } from "../../utils/validateTypes";
import { sassConditionalBraceNLAfterChecker } from "../at-if-closing-brace-newline-after";

export const ruleName = namespace("at-else-closing-brace-newline-after");
Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-function-named-arguments/index.js
@@ -1,4 +1,4 @@
import { isString } from "stylelint/lib/utils/validateTypes";
import { isString } from "../../utils/validateTypes";
import valueParser from "postcss-value-parser";
import { utils } from "stylelint";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-function-pattern/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { utils } from "stylelint";
import { namespace, ruleUrl } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-if-closing-brace-newline-after/index.js
@@ -1,6 +1,6 @@
import { isSingleLineString, namespace, ruleUrl } from "../../utils";
import { utils } from "stylelint";
import { isBoolean } from "stylelint/lib/utils/validateTypes";
import { isBoolean } from "../../utils/validateTypes";

export const ruleName = namespace("at-if-closing-brace-newline-after");

Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-import-partial-extension-blacklist/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { utils } from "stylelint";
import { namespace, ruleUrl } from "../../utils";
import nodeJsPath from "path";
Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-import-partial-extension-whitelist/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { utils } from "stylelint";
import { namespace, ruleUrl } from "../../utils";
import nodeJsPath from "path";
Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-mixin-pattern/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { utils } from "stylelint";
import { namespace, ruleUrl } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/rules/at-rule-no-unknown/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { rules, utils } from "stylelint";
import { namespace, ruleUrl } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/rules/dollar-variable-colon-newline-after/index.js
@@ -1,4 +1,4 @@
import { isBoolean } from "stylelint/lib/utils/validateTypes";
import { isBoolean } from "../../utils/validateTypes";
import { utils } from "stylelint";
import {
declarationValueIndex,
Expand Down
2 changes: 1 addition & 1 deletion src/rules/dollar-variable-empty-line-after/index.js
Expand Up @@ -8,7 +8,7 @@ import {
ruleUrl
} from "../../utils";
import { utils } from "stylelint";
import { isBoolean } from "stylelint/lib/utils/validateTypes";
import { isBoolean } from "../../utils/validateTypes";

export const ruleName = namespace("dollar-variable-empty-line-after");

Expand Down
2 changes: 1 addition & 1 deletion src/rules/dollar-variable-empty-line-before/index.js
Expand Up @@ -8,7 +8,7 @@ import {
ruleUrl
} from "../../utils";
import { utils } from "stylelint";
import { isBoolean } from "stylelint/lib/utils/validateTypes";
import { isBoolean } from "../../utils/validateTypes";

export const ruleName = namespace("dollar-variable-empty-line-before");

Expand Down
2 changes: 1 addition & 1 deletion src/rules/dollar-variable-pattern/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { utils } from "stylelint";
import { namespace, optionsHaveIgnored, ruleUrl } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion src/rules/function-no-unknown/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import { rules, utils } from "stylelint";
import valueParser from "postcss-value-parser";
import { namespace, ruleUrl, ALL_FUNCTIONS } from "../../utils";
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-duplicate-dollar-variables/index.js
@@ -1,5 +1,5 @@
import { utils } from "stylelint";
import { isString, isBoolean } from "stylelint/lib/utils/validateTypes";
import { isString, isBoolean } from "../../utils/validateTypes";
import { namespace, ruleUrl } from "../../utils";

export const ruleName = namespace("no-duplicate-dollar-variables");
Expand Down
2 changes: 1 addition & 1 deletion src/rules/percent-placeholder-pattern/index.js
@@ -1,4 +1,4 @@
import { isRegExp, isString } from "stylelint/lib/utils/validateTypes";
import { isRegExp, isString } from "../../utils/validateTypes";
import resolveNestedSelector from "postcss-resolve-nested-selector";
import { utils } from "stylelint";
import {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/selector-no-redundant-nesting-selector/index.js
@@ -1,6 +1,6 @@
import { utils } from "stylelint";
import optionsMatches from "stylelint/lib/utils/optionsMatches";
import { isString, isRegExp } from "stylelint/lib/utils/validateTypes";
import { isString, isRegExp } from "../../utils/validateTypes";
import {
namespace,
parseSelector,
Expand Down
35 changes: 35 additions & 0 deletions src/utils/validateTypes.js
@@ -0,0 +1,35 @@
/**
* Checks if the value is a boolean or a Boolean object.
* @param {unknown} value
* @returns {value is boolean}
*/
export function isBoolean(value) {
return typeof value === "boolean" || value instanceof Boolean;
}

/**
* Checks if the value is a number or a Number object.
* @param {unknown} value
* @returns {value is number}
*/
export function isNumber(value) {
return typeof value === "number" || value instanceof Number;
}

/**
* Checks if the value is a RegExp object.
* @param {unknown} value
* @returns {value is RegExp}
*/
export function isRegExp(value) {
return value instanceof RegExp;
}

/**
* Checks if the value is a string or a String object.
* @param {unknown} value
* @returns {value is string}
*/
export function isString(value) {
return typeof value === "string" || value instanceof String;
}

0 comments on commit afa67c3

Please sign in to comment.