UNPKG

stylelint-itcss

Version:
64 lines 2.8 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../index"); const ava_1 = require("ava"); const stylelint = require("stylelint"); function ruleConfig(config = [true]) { return { plugins: ["./dist/src"], rules: { [index_1.ruleName]: config, } }; } ava_1.default.serial(`${index_1.ruleName} - inline code - OK`, (t) => __awaiter(void 0, void 0, void 0, function* () { const options = { code: "a{color:blue}", config: ruleConfig() // syntax: syntax, }; const output = yield stylelint.lint(options); t.falsy(output.errored); })); ava_1.default.serial(`${index_1.ruleName} - inline code - KO`, (t) => __awaiter(void 0, void 0, void 0, function* () { const options = { code: "a{color:blue!important}", config: ruleConfig(), }; const output = yield stylelint.lint(options); t.true(output.errored); })); ava_1.default.serial(`${index_1.ruleName} - layers options - ok`, (t) => __awaiter(void 0, void 0, void 0, function* () { const options = { files: ["**/no-at-important/__tests__/fixtures/_layer.style.css"], config: ruleConfig([true, { ignoreLayers: ["layer"] }]), }; const output = yield stylelint.lint(options); t.false(output.errored); })); ava_1.default.serial(`${index_1.ruleName} - layers options - ko`, (t) => __awaiter(void 0, void 0, void 0, function* () { const options = { files: ["**/no-at-important/__tests__/fixtures/style.css"], config: ruleConfig([true, { ignoreLayers: ["layer"] }]), }; const output = yield stylelint.lint(options); t.true(output.errored); const warnings = output.results[0].warnings; t.is(warnings.length, 3); t.is(warnings[0].line, 2); t.is(warnings[0].column, 3); // should the position of !important t.is(warnings[1].line, 5); t.is(warnings[1].column, 3); // should the position of !important t.is(warnings[2].line, 8); t.is(warnings[2].column, 3); // should the position of !important })); //# sourceMappingURL=index.js.map