@pandacss/eslint-plugin 2.0.0-beta.15 → 2.0.0-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -425,6 +425,85 @@ function report(context, kind, name, deprecation, range) {
425
425
  });
426
426
  }
427
427
 
428
+ // src/rules/no-descendant-selectors.ts
429
+ var noDescendantSelectorsRuleName = "no-descendant-selectors";
430
+ function* topLevelChars(selector) {
431
+ let depth = 0;
432
+ let quote;
433
+ for (let i = 0; i < selector.length; i++) {
434
+ const ch = selector[i];
435
+ if (quote) {
436
+ if (ch === "\\") i++;
437
+ else if (ch === quote) quote = void 0;
438
+ continue;
439
+ }
440
+ if (ch === "\\") {
441
+ i++;
442
+ continue;
443
+ }
444
+ if (ch === '"' || ch === "'") {
445
+ quote = ch;
446
+ continue;
447
+ }
448
+ if (ch === "[" || ch === "(") depth++;
449
+ else if (ch === "]" || ch === ")") depth--;
450
+ else if (depth === 0) yield [i, ch];
451
+ }
452
+ }
453
+ function splitSelectorList(selector) {
454
+ const cuts = [];
455
+ for (const [i, ch] of topLevelChars(selector)) {
456
+ if (ch === ",") cuts.push(i);
457
+ }
458
+ const parts = [];
459
+ let start = 0;
460
+ for (const cut of cuts) {
461
+ parts.push(selector.slice(start, cut));
462
+ start = cut + 1;
463
+ }
464
+ parts.push(selector.slice(start));
465
+ return parts.map((p) => p.trim()).filter(Boolean);
466
+ }
467
+ function targetsOtherElement(part) {
468
+ if (!part.includes("&")) return false;
469
+ for (const [, ch] of topLevelChars(part)) {
470
+ if (ch === " " || ch === " " || ch === ">" || ch === "+" || ch === "~") return true;
471
+ }
472
+ return false;
473
+ }
474
+ function createNoDescendantSelectorsRule(options) {
475
+ return {
476
+ meta: {
477
+ type: "suggestion",
478
+ docs: {
479
+ description: "Disallow selectors that style other elements, keeping every style scoped to its own element."
480
+ },
481
+ schema: [],
482
+ messages: {
483
+ descendant: 'Selector "{{selector}}" styles another element. Keep styles on the element they belong to, or use a condition like "_groupHover" for cross-element state.'
484
+ }
485
+ },
486
+ create(context) {
487
+ return {
488
+ Program() {
489
+ const inspection = options.inspect(context);
490
+ if (!inspection) return;
491
+ for (const entry of inspection.styleEntries) {
492
+ if (entry.kind !== "selector") continue;
493
+ if (entry.origin === "generated") continue;
494
+ if (!splitSelectorList(entry.name).some(targetsOtherElement)) continue;
495
+ context.report({
496
+ messageId: "descendant",
497
+ data: { selector: entry.name },
498
+ loc: toEslintLoc(entry.range)
499
+ });
500
+ }
501
+ }
502
+ };
503
+ }
504
+ };
505
+ }
506
+
428
507
  // src/rules/no-important.ts
429
508
  var noImportantRuleName = "no-important";
430
509
  var MESSAGE3 = "Avoid `!important`; it escalates specificity and is hard to override.";
@@ -1044,7 +1123,7 @@ import { SpecIndex } from "@pandacss/compiler/tooling";
1044
1123
  // package.json
1045
1124
  var package_default = {
1046
1125
  name: "@pandacss/eslint-plugin",
1047
- version: "2.0.0-beta.15",
1126
+ version: "2.0.0-beta.17",
1048
1127
  description: "ESLint rules for Panda CSS",
1049
1128
  keywords: [
1050
1129
  "eslint",
@@ -1097,8 +1176,8 @@ var package_default = {
1097
1176
  "@pandacss/config": "workspace:*"
1098
1177
  },
1099
1178
  devDependencies: {
1100
- "@typescript-eslint/parser": "8.58.2",
1101
- eslint: "9.39.1"
1179
+ "@typescript-eslint/parser": "8.69.0",
1180
+ eslint: "9.39.5"
1102
1181
  },
1103
1182
  peerDependencies: {
1104
1183
  eslint: ">=9"
@@ -1191,6 +1270,7 @@ function bindRules(linter, project) {
1191
1270
  [noPrimitiveTokenRuleName]: createNoPrimitiveTokenRule({ inspect, suggestSemanticTokens }),
1192
1271
  // Opt-in style/enforcement rules (not in `recommended`).
1193
1272
  [noImportantRuleName]: createNoImportantRule({ inspect }),
1273
+ [noDescendantSelectorsRuleName]: createNoDescendantSelectorsRule({ inspect }),
1194
1274
  [noMarginPropertiesRuleName]: createNoMarginPropertiesRule({ inspect }),
1195
1275
  [noPhysicalPropertiesRuleName]: createNoPhysicalPropertiesRule({ inspect }),
1196
1276
  [noShorthandLonghandMixRuleName]: createNoShorthandLonghandMixRule({ inspect }),
@@ -1235,6 +1315,8 @@ export {
1235
1315
  createNoDebugRule,
1236
1316
  noDeprecatedRuleName,
1237
1317
  createNoDeprecatedRule,
1318
+ noDescendantSelectorsRuleName,
1319
+ createNoDescendantSelectorsRule,
1238
1320
  noImportantRuleName,
1239
1321
  createNoImportantRule,
1240
1322
  noInvalidNestingRuleName,
package/dist/index.d.ts CHANGED
@@ -132,6 +132,11 @@ interface NoDeprecatedRuleOptions {
132
132
  }
133
133
  declare function createNoDeprecatedRule(options: NoDeprecatedRuleOptions): RuleModuleLike;
134
134
 
135
+ declare const noDescendantSelectorsRuleName = "no-descendant-selectors";
136
+ declare function createNoDescendantSelectorsRule(options: {
137
+ inspect: Inspect;
138
+ }): RuleModuleLike;
139
+
135
140
  declare const noImportantRuleName = "no-important";
136
141
  declare function createNoImportantRule(options: {
137
142
  inspect: Inspect;
@@ -211,4 +216,4 @@ declare const _default: {
211
216
  };
212
217
  };
213
218
 
214
- export { type ConsistentPropertyStyleRuleOptions, type DeprecationKind, type ExtractionDiagnosticsRuleOptions, type FileNotIncludedRuleOptions, Inspect, Linter, type NoDebugRuleOptions, type NoDeprecatedRuleOptions, type NoPrimitiveTokenRuleOptions, PLUGIN_NAMESPACE, type PandaFlatConfig, type PandaPlugin, type PandaPluginOptions, type PandaProject, type PreferTokenRuleOptions, RangeIndex, type RangeLike, type RecommendedOptions, RuleContextWithReport, RuleModuleLike, type SuggestTokens, type TokenRuleOptions, bindRules, collectStrings, configs, consistentPropertyStyleRuleName, createConsistentPropertyStyleRule, createExtractionDiagnosticsRule, createFileNotIncludedRule, createNoDebugRule, createNoDeprecatedRule, createNoImportantRule, createNoInvalidNestingRule, createNoInvalidTokenPathsRule, createNoMarginPropertiesRule, createNoPhysicalPropertiesRule, createNoPrimitiveTokenRule, createNoShorthandLonghandMixRule, createPandaPlugin, createPreferTextStyleRule, createPreferTokenRule, _default as default, extractionDiagnosticsRuleName, fileNotIncludedRuleName, loadPandaProject, noDebugRuleName, noDeprecatedRuleName, noImportantRuleName, noInvalidNestingRuleName, noInvalidTokenPathsRuleName, noMarginPropertiesRuleName, noPhysicalPropertiesRuleName, noPrimitiveTokenRuleName, noShorthandLonghandMixRuleName, pluginMeta, preferTextStyleRuleName, preferTokenRuleName, recommended, reportDiagnostics, reportPrimitiveTokenViolations, reportTokenViolations };
219
+ export { type ConsistentPropertyStyleRuleOptions, type DeprecationKind, type ExtractionDiagnosticsRuleOptions, type FileNotIncludedRuleOptions, Inspect, Linter, type NoDebugRuleOptions, type NoDeprecatedRuleOptions, type NoPrimitiveTokenRuleOptions, PLUGIN_NAMESPACE, type PandaFlatConfig, type PandaPlugin, type PandaPluginOptions, type PandaProject, type PreferTokenRuleOptions, RangeIndex, type RangeLike, type RecommendedOptions, RuleContextWithReport, RuleModuleLike, type SuggestTokens, type TokenRuleOptions, bindRules, collectStrings, configs, consistentPropertyStyleRuleName, createConsistentPropertyStyleRule, createExtractionDiagnosticsRule, createFileNotIncludedRule, createNoDebugRule, createNoDeprecatedRule, createNoDescendantSelectorsRule, createNoImportantRule, createNoInvalidNestingRule, createNoInvalidTokenPathsRule, createNoMarginPropertiesRule, createNoPhysicalPropertiesRule, createNoPrimitiveTokenRule, createNoShorthandLonghandMixRule, createPandaPlugin, createPreferTextStyleRule, createPreferTokenRule, _default as default, extractionDiagnosticsRuleName, fileNotIncludedRuleName, loadPandaProject, noDebugRuleName, noDeprecatedRuleName, noDescendantSelectorsRuleName, noImportantRuleName, noInvalidNestingRuleName, noInvalidTokenPathsRuleName, noMarginPropertiesRuleName, noPhysicalPropertiesRuleName, noPrimitiveTokenRuleName, noShorthandLonghandMixRuleName, pluginMeta, preferTextStyleRuleName, preferTokenRuleName, recommended, reportDiagnostics, reportPrimitiveTokenViolations, reportTokenViolations };
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  createFileNotIncludedRule,
12
12
  createNoDebugRule,
13
13
  createNoDeprecatedRule,
14
+ createNoDescendantSelectorsRule,
14
15
  createNoImportantRule,
15
16
  createNoInvalidNestingRule,
16
17
  createNoInvalidTokenPathsRule,
@@ -29,6 +30,7 @@ import {
29
30
  loadPandaProject,
30
31
  noDebugRuleName,
31
32
  noDeprecatedRuleName,
33
+ noDescendantSelectorsRuleName,
32
34
  noImportantRuleName,
33
35
  noInvalidNestingRuleName,
34
36
  noInvalidTokenPathsRuleName,
@@ -46,7 +48,7 @@ import {
46
48
  resolvePandaSettings,
47
49
  sourceCacheKey,
48
50
  toEslintLoc
49
- } from "./chunk-MXVBHPDY.js";
51
+ } from "./chunk-ZZIBT6P3.js";
50
52
 
51
53
  // src/core/range-index.ts
52
54
  var RangeIndex = class {
@@ -115,6 +117,7 @@ export {
115
117
  createFileNotIncludedRule,
116
118
  createNoDebugRule,
117
119
  createNoDeprecatedRule,
120
+ createNoDescendantSelectorsRule,
118
121
  createNoImportantRule,
119
122
  createNoInvalidNestingRule,
120
123
  createNoInvalidTokenPathsRule,
@@ -134,6 +137,7 @@ export {
134
137
  loadPandaProject,
135
138
  noDebugRuleName,
136
139
  noDeprecatedRuleName,
140
+ noDescendantSelectorsRuleName,
137
141
  noImportantRuleName,
138
142
  noInvalidNestingRuleName,
139
143
  noInvalidTokenPathsRuleName,
package/dist/oxlint.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createPandaPlugin
3
- } from "./chunk-MXVBHPDY.js";
3
+ } from "./chunk-ZZIBT6P3.js";
4
4
 
5
5
  // src/oxlint.ts
6
6
  var configPath = process.env.PANDA_CONFIG_PATH;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/eslint-plugin",
3
- "version": "2.0.0-beta.15",
3
+ "version": "2.0.0-beta.17",
4
4
  "description": "ESLint rules for Panda CSS",
5
5
  "keywords": [
6
6
  "eslint",
@@ -42,13 +42,13 @@
42
42
  "dist"
43
43
  ],
44
44
  "dependencies": {
45
- "@pandacss/compiler": "2.0.0-beta.15",
46
- "@pandacss/compiler-shared": "2.0.0-beta.15",
47
- "@pandacss/config": "2.0.0-beta.15"
45
+ "@pandacss/compiler": "2.0.0-beta.17",
46
+ "@pandacss/compiler-shared": "2.0.0-beta.17",
47
+ "@pandacss/config": "2.0.0-beta.17"
48
48
  },
49
49
  "devDependencies": {
50
- "@typescript-eslint/parser": "8.58.2",
51
- "eslint": "9.39.1"
50
+ "@typescript-eslint/parser": "8.69.0",
51
+ "eslint": "9.39.5"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "eslint": ">=9"