@lvce-editor/eslint-plugin-eslint-config 18.14.2 → 18.16.0

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.
Files changed (2) hide show
  1. package/dist/index.js +76 -3
  2. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import css from '@eslint/css';
2
+
1
3
  const eslintConfigModule = 'eslint/config';
2
4
  const defineConfigName = 'defineConfig';
3
5
  const getImportedName = specifier => {
@@ -50,7 +52,7 @@ const isDefineConfigCall = (node, bindings) => {
50
52
  }
51
53
  return callee.type === 'MemberExpression' && callee.object.type === 'Identifier' && bindings.namespaces.has(callee.object.name) && isDefineConfigProperty(callee);
52
54
  };
53
- const meta$2 = {
55
+ const meta$3 = {
54
56
  docs: {
55
57
  description: 'Enforce using defineConfig from eslint/config for ESLint flat configurations'
56
58
  },
@@ -59,7 +61,7 @@ const meta$2 = {
59
61
  },
60
62
  type: 'suggestion'
61
63
  };
62
- const create$2 = context => {
64
+ const create$3 = context => {
63
65
  return {
64
66
  'Program:exit'(program) {
65
67
  const bindings = getDefineConfigBindings(program);
@@ -76,6 +78,65 @@ const create$2 = context => {
76
78
  };
77
79
 
78
80
  const defineConfig = {
81
+ __proto__: null,
82
+ create: create$3,
83
+ meta: meta$3
84
+ };
85
+
86
+ const containsQuickPickItem = node => {
87
+ if (!node) {
88
+ return false;
89
+ }
90
+ if (node.type === 'ClassSelector' && node.name === 'QuickPickItem') {
91
+ return true;
92
+ }
93
+ let found = false;
94
+ const children = node.children ?? [];
95
+ for (const child of children) {
96
+ found ||= containsQuickPickItem(child);
97
+ }
98
+ return found;
99
+ };
100
+ const meta$2 = {
101
+ docs: {
102
+ description: 'Disallow strict containment on quick-pick result rows'
103
+ },
104
+ messages: {
105
+ avoidStrictContainment: 'Avoid contain: strict on .QuickPickItem rows; it increases quick-pick paint events. Use size/style containment when appropriate.'
106
+ },
107
+ type: 'problem'
108
+ };
109
+ const create$2 = context => {
110
+ const sourceCode = context.sourceCode;
111
+ return {
112
+ Rule(cssRule) {
113
+ if (cssRule.type !== 'Rule' || !cssRule.prelude?.children || !cssRule.block?.children) {
114
+ return;
115
+ }
116
+ let appliesToQuickPickItem = false;
117
+ for (const selector of cssRule.prelude.children) {
118
+ appliesToQuickPickItem ||= containsQuickPickItem(selector);
119
+ }
120
+ if (!appliesToQuickPickItem) {
121
+ return;
122
+ }
123
+ for (const declaration of cssRule.block.children) {
124
+ if (declaration.type !== 'Declaration' || declaration.property.toLowerCase() !== 'contain') {
125
+ return;
126
+ }
127
+ const value = sourceCode.getText(declaration.value).replaceAll(/\/\*[\s\S]*?\*\//gu, '').trim();
128
+ if (/^strict$/iu.test(value)) {
129
+ context.report({
130
+ messageId: 'avoidStrictContainment',
131
+ node: declaration
132
+ });
133
+ }
134
+ }
135
+ }
136
+ };
137
+ };
138
+
139
+ const noStrictContainmentQuickPickItem = {
79
140
  __proto__: null,
80
141
  create: create$2,
81
142
  meta: meta$2
@@ -153,6 +214,7 @@ const plugin = {
153
214
  },
154
215
  rules: {
155
216
  'define-config': defineConfig,
217
+ 'no-strict-containment-quickpick-item': noStrictContainmentQuickPickItem,
156
218
  'prefer-recommended-actions': preferRecommendedActions,
157
219
  'prefer-recommended-regex': preferRecommendedRegex
158
220
  }
@@ -168,5 +230,16 @@ const recommended = [{
168
230
  'eslint-config/prefer-recommended-regex': 'error'
169
231
  }
170
232
  }];
233
+ const recommendedQuickPickCss = [{
234
+ files: ['**/*.css'],
235
+ language: 'css/css',
236
+ plugins: {
237
+ css,
238
+ 'eslint-config': plugin
239
+ },
240
+ rules: {
241
+ 'eslint-config/no-strict-containment-quickpick-item': 'error'
242
+ }
243
+ }];
171
244
 
172
- export { recommended as default };
245
+ export { recommended as default, recommendedQuickPickCss };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/eslint-plugin-eslint-config",
3
- "version": "18.14.2",
3
+ "version": "18.16.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,5 +8,8 @@
8
8
  },
9
9
  "type": "module",
10
10
  "license": "MIT",
11
- "description": "ESLint rules for ESLint flat configuration files."
11
+ "description": "ESLint rules for ESLint flat configuration files.",
12
+ "dependencies": {
13
+ "@eslint/css": "^2.0.1"
14
+ }
12
15
  }