Skip to content

Commit

Permalink
use fewer negative lookahead assertions in regular expressions (Schem…
Browse files Browse the repository at this point in the history
  • Loading branch information
rogpeppe authored and benpops89 committed Nov 21, 2024
1 parent d455072 commit fd1ac77
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 31 deletions.
15 changes: 15 additions & 0 deletions src/negative_test/stylelintrc/objectRule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"declaration-property-unit-whitelist": [
{
"message": []
},
{
"/^animation/": "s",
"font-size": "em",
"line-height": [],
"message": []
}
]
}
}
2 changes: 1 addition & 1 deletion src/schemas/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
}
},
"patternProperties": {
"^(?![\\.0-9]).": {
"^[^.0-9]+$": {
"$ref": "#/definitions/packageExportsEntryOrFallback",
"description": "The module path that is resolved when this environment matches the property name."
}
Expand Down
46 changes: 16 additions & 30 deletions src/schemas/json/stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@
"type": "null"
},
{
"type": "boolean",
"enum": [true, []]
"type": "boolean"
},
{
"type": "array",
Expand All @@ -205,8 +204,7 @@
"type": ["boolean", "object"],
"anyOf": [
{
"type": "boolean",
"enum": [true, {}]
"type": "boolean"
},
{
"$ref": "#/definitions/coreRule"
Expand All @@ -217,6 +215,7 @@
]
},
"coreRule": {
"type": "object",
"properties": {
"disableFix": {
"type": "boolean"
Expand Down Expand Up @@ -427,48 +426,36 @@
]
},
"objectRule": {
"type": ["null", "object", "array"],
"oneOf": [
{
"type": "null"
},
{
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/definitions/simpleArrayStringRule"
}
"additionalProperties": {
"$ref": "#/definitions/simpleStringOrArrayStringRule"
}
},
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"type": ["object"],
"anyOf": [
{
"type": "object",
"allOf": [
{
"$ref": "#/definitions/coreRule"
}
],
"patternProperties": {
"^((?!message|severity).)*$": {
"$ref": "#/definitions/simpleArrayStringRule"
}
}
"items": [
{
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/simpleStringOrArrayStringRule"
}
]
}
},
{
"$ref": "#/definitions/coreRule"
}
]
}
]
},
"simpleArrayStringRule": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"type": "string"
Expand Down Expand Up @@ -572,8 +559,7 @@
"type": ["string", "object"],
"anyOf": [
{
"type": "string",
"enum": [{}]
"type": "string"
},
{
"$ref": "#/definitions/coreRule"
Expand Down
15 changes: 15 additions & 0 deletions src/test/stylelintrc/objectRule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"rules": {
"declaration-property-unit-whitelist": [
{
"/^animation/": "s",
"/message/": "blah",
"font-size": "em",
"line-height": []
},
{
"message": "it failed!"
}
]
}
}

0 comments on commit fd1ac77

Please sign in to comment.