Skip to content

Commit

Permalink
Remove support for Stylelint less than 16.0.0 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddy3 authored Dec 8, 2023
1 parent 92d45f8 commit a90f76e
Show file tree
Hide file tree
Showing 43 changed files with 1,651 additions and 6,523 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"jest": true
},
"parserOptions": {
"ecmaVersion": "latest"
"ecmaVersion": "latest",
"sourceType": "module"
},
"globals": {
"testRule": true
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Head

## Removed

- support for Stylelint less than 16.0.0

## 3.1.1

### Fixed
Expand Down
4 changes: 0 additions & 4 deletions jest.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions jest.setup.js

This file was deleted.

36 changes: 24 additions & 12 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
module.exports = [
require("./rules/alpha-values"),
require("./rules/border-widths"),
require("./rules/font-sizes"),
require("./rules/font-weights"),
require("./rules/letter-spacings"),
require("./rules/line-heights"),
require("./rules/radii"),
require("./rules/sizes"),
require("./rules/space"),
require("./rules/word-spacings"),
require("./rules/z-indices"),
import alphaValues from "./rules/alpha-values/index.js";
import borderWidths from "./rules/border-widths/index.js";
import fontSizes from "./rules/font-sizes/index.js";
import fontWeights from "./rules/font-weights/index.js";
import letterSpacings from "./rules/letter-spacings/index.js";
import lineHeights from "./rules/line-heights/index.js";
import radii from "./rules/radii/index.js";
import sizes from "./rules/sizes/index.js";
import space from "./rules/space/index.js";
import wordSpacings from "./rules/word-spacings/index.js";
import zIndices from "./rules/z-indices/index.js";

export default [
alphaValues,
borderWidths,
fontSizes,
fontWeights,
letterSpacings,
lineHeights,
radii,
sizes,
space,
wordSpacings,
zIndices,
];
32 changes: 20 additions & 12 deletions lib/rules/alpha-values/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
const { parse } = require("postcss-values-parser");
import { parse } from "postcss-values-parser";
import stylelint from "stylelint";

import createRuleMessages from "../../utils/createRuleMessages.js";
import getClosest from "../../utils/getClosest.js";
import getValue from "../../utils/getValue.js";
import hasNumericScale from "../../utils/hasNumericScale.js";
import isOnNumericScale from "../../utils/isOnNumericScale.js";
import setValue from "../../utils/setValue.js";

const {
createPlugin,
utils: { report, validateOptions },
} = require("stylelint");

const createRuleMessages = require("../../utils/createRuleMessages");
const getClosest = require("../../utils/getClosest");
const getValue = require("../../utils/getValue");
const hasNumericScale = require("../../utils/hasNumericScale");
const isOnNumericScale = require("../../utils/isOnNumericScale");
const setValue = require("../../utils/setValue");
} = stylelint;

const ruleName = "scales/alpha-values";
const messages = createRuleMessages(ruleName);
const meta = {
url: "https://github.com/jeddy3/stylelint-scales/blob/main/lib/rules/alpha-values/README.md",
fixable: true,
};

const alphaValueProperties = new Set(["opacity", "shape-image-threshold"]);
const alphaValueFunctions = new Set(["hsl", "hwb", "lab", "lch", "rgb"]);
Expand Down Expand Up @@ -106,6 +112,8 @@ function findAlphaValue(nodes) {

rule.primaryOptionArray = true;

module.exports = createPlugin(ruleName, rule);
module.exports.ruleName = ruleName;
module.exports.messages = messages;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;

export default createPlugin(ruleName, rule);
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
const { stripIndent } = require("common-tags");
import { stripIndent } from "common-tags";
import { testRule } from "stylelint-test-rule-node";

const { messages, ruleName } = require("..");
import plugin from "./index.js";
const {
rule: { messages, ruleName },
} = plugin;

testRule({
ruleName,
config: [10, 20],
fix: true,
plugins: [plugin],

accept: [
{
Expand Down
34 changes: 21 additions & 13 deletions lib/rules/border-widths/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const { parse } = require("postcss-values-parser");
import { parse } from "postcss-values-parser";
import stylelint from "stylelint";

import createRuleMessages from "../../utils/createRuleMessages.js";
import findScaleByUnit from "../../utils/findScaleByUnit.js";
import getClosest from "../../utils/getClosest.js";
import getValue from "../../utils/getValue.js";
import hasScalesWithUnits from "../../utils/hasScalesWithUnits.js";
import isOnNumericScale from "../../utils/isOnNumericScale.js";
import setValue from "../../utils/setValue.js";

const {
createPlugin,
utils: { report, validateOptions },
} = require("stylelint");

const createRuleMessages = require("../../utils/createRuleMessages");
const findScaleByUnit = require("../../utils/findScaleByUnit");
const getClosest = require("../../utils/getClosest");
const getValue = require("../../utils/getValue");
const hasScalesWithUnits = require("../../utils/hasScalesWithUnits");
const isOnNumericScale = require("../../utils/isOnNumericScale");
const setValue = require("../../utils/setValue");
} = stylelint;

const ruleName = "scales/border-widths";
const messages = createRuleMessages(ruleName);
const meta = {
url: "https://github.com/jeddy3/stylelint-scales/blob/main/lib/rules/border-widths/README.md",
fixable: true,
};

const propertyFilter =
/^border$|^border.*(width$|top$|right$|bottom$|left$|block$|inline$|start$|end$)/;
Expand Down Expand Up @@ -69,6 +75,8 @@ const rule = (primary, secondary, { fix }) => {

rule.primaryOptionArray = true;

module.exports = createPlugin(ruleName, rule);
module.exports.ruleName = ruleName;
module.exports.messages = messages;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;

export default createPlugin(ruleName, rule);
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const { messages, ruleName } = require("..");
import { testRule } from "stylelint-test-rule-node";

import plugin from "./index.js";

const {
rule: { messages, ruleName },
} = plugin;

testRule({
ruleName,
Expand All @@ -9,6 +15,7 @@ testRule({
},
],
fix: true,
plugins: [plugin],

accept: [
{
Expand Down
40 changes: 24 additions & 16 deletions lib/rules/font-sizes/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
const { parse } = require("postcss-values-parser");
import { parse } from "postcss-values-parser";
import stylelint from "stylelint";

import createRuleMessages from "../../utils/createRuleMessages.js";
import findScaleByUnit from "../../utils/findScaleByUnit.js";
import getClosest from "../../utils/getClosest.js";
import getValue from "../../utils/getValue.js";
import hasScalesWithUnits from "../../utils/hasScalesWithUnits.js";
import hasObjectWithNumericArray from "../../utils/hasObjectWithNumericArray.js";
import isIgnoredFunctionArgument from "../../utils/isIgnoredFunctionArgument.js";
import isLineHeight from "../../utils/isLineHeight.js";
import isOnNumericScale from "../../utils/isOnNumericScale.js";
import setValue from "../../utils/setValue.js";

const {
createPlugin,
utils: { report, validateOptions },
} = require("stylelint");

const createRuleMessages = require("../../utils/createRuleMessages");
const findScaleByUnit = require("../../utils/findScaleByUnit");
const getClosest = require("../../utils/getClosest");
const getValue = require("../../utils/getValue");
const hasScalesWithUnits = require("../../utils/hasScalesWithUnits");
const hasObjectWithNumericArray = require("../../utils/hasObjectWithNumericArray");
const isIgnoredFunctionArgument = require("../../utils/isIgnoredFunctionArgument");
const isLineHeight = require("../../utils/isLineHeight");
const isOnNumericScale = require("../../utils/isOnNumericScale");
const setValue = require("../../utils/setValue");
} = stylelint;

const ruleName = "scales/font-sizes";
const messages = createRuleMessages(ruleName);
const meta = {
url: "https://github.com/jeddy3/stylelint-scales/blob/main/lib/rules/font-sizes/README.md",
fixable: true,
};

const propertyFilter = /^font-size$|^font$/;

Expand Down Expand Up @@ -104,6 +110,8 @@ function findFontSize(nodes) {

rule.primaryOptionArray = true;

module.exports = createPlugin(ruleName, rule);
module.exports.ruleName = ruleName;
module.exports.messages = messages;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;

export default createPlugin(ruleName, rule);
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
const { messages, ruleName } = require("..");
import { testRule } from "stylelint-test-rule-node";

import plugin from "./index.js";

const {
rule: { messages, ruleName },
} = plugin;

testRule({
ruleName,
Expand All @@ -9,6 +15,7 @@ testRule({
},
],
fix: true,
plugins: [plugin],

accept: [
{
Expand Down Expand Up @@ -72,6 +79,7 @@ testRule({
},
],
fix: true,
plugins: [plugin],

accept: [
{
Expand Down
34 changes: 21 additions & 13 deletions lib/rules/font-weights/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const { parse } = require("postcss-values-parser");
import { parse } from "postcss-values-parser";
import stylelint from "stylelint";

import createRuleMessages from "../../utils/createRuleMessages.js";
import getClosest from "../../utils/getClosest.js";
import getValue from "../../utils/getValue.js";
import hasNumericScale from "../../utils/hasNumericScale.js";
import isLineHeight from "../../utils/isLineHeight.js";
import isOnNumericScale from "../../utils/isOnNumericScale.js";
import setValue from "../../utils/setValue.js";

const {
createPlugin,
utils: { report, validateOptions },
} = require("stylelint");

const createRuleMessages = require("../../utils/createRuleMessages");
const getClosest = require("../../utils/getClosest");
const getValue = require("../../utils/getValue");
const hasNumericScale = require("../../utils/hasNumericScale");
const isLineHeight = require("../../utils/isLineHeight");
const isOnNumericScale = require("../../utils/isOnNumericScale");
const setValue = require("../../utils/setValue");
} = stylelint;

const ruleName = "scales/font-weights";
const messages = createRuleMessages(ruleName);
const meta = {
url: "https://github.com/jeddy3/stylelint-scales/blob/main/lib/rules/font-weights/README.md",
fixable: true,
};

const propertyFilter = /^font-weight$|^font$/;

Expand Down Expand Up @@ -86,6 +92,8 @@ function findFontWeight(nodes) {

rule.primaryOptionArray = true;

module.exports = createPlugin(ruleName, rule);
module.exports.ruleName = ruleName;
module.exports.messages = messages;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;

export default createPlugin(ruleName, rule);
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const { messages, ruleName } = require("..");
import { testRule } from "stylelint-test-rule-node";

import plugin from "./index.js";

const {
rule: { messages, ruleName },
} = plugin;

testRule({
ruleName,
config: [400, 700],
fix: true,
plugins: [plugin],

accept: [
{
Expand Down
34 changes: 21 additions & 13 deletions lib/rules/letter-spacings/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
const { parse } = require("postcss-values-parser");
import { parse } from "postcss-values-parser";
import stylelint from "stylelint";

import createRuleMessages from "../../utils/createRuleMessages.js";
import findScaleByUnit from "../../utils/findScaleByUnit.js";
import getClosest from "../../utils/getClosest.js";
import getValue from "../../utils/getValue.js";
import hasScalesWithUnits from "../../utils/hasScalesWithUnits.js";
import isOnNumericScale from "../../utils/isOnNumericScale.js";
import setValue from "../../utils/setValue.js";

const {
createPlugin,
utils: { report, validateOptions },
} = require("stylelint");

const createRuleMessages = require("../../utils/createRuleMessages");
const findScaleByUnit = require("../../utils/findScaleByUnit");
const getClosest = require("../../utils/getClosest");
const getValue = require("../../utils/getValue");
const hasScalesWithUnits = require("../../utils/hasScalesWithUnits");
const isOnNumericScale = require("../../utils/isOnNumericScale");
const setValue = require("../../utils/setValue");
} = stylelint;

const ruleName = "scales/letter-spacings";
const messages = createRuleMessages(ruleName);
const meta = {
url: "https://github.com/jeddy3/stylelint-scales/blob/main/lib/rules/letter-spacings/README.md",
fixable: true,
};

const propertyFilter = "letter-spacing";

Expand Down Expand Up @@ -68,6 +74,8 @@ const rule = (primary, secondary, { fix }) => {

rule.primaryOptionArray = true;

module.exports = createPlugin(ruleName, rule);
module.exports.ruleName = ruleName;
module.exports.messages = messages;
rule.ruleName = ruleName;
rule.messages = messages;
rule.meta = meta;

export default createPlugin(ruleName, rule);
Loading

0 comments on commit a90f76e

Please sign in to comment.