mirror of
https://github.com/langgenius/dify.git
synced 2026-04-25 13:16:16 +08:00
Fix ESLint selector - use simpler selector with runtime filtering instead of dynamic regex
Co-authored-by: hyoban <38493346+hyoban@users.noreply.github.com>
This commit is contained in:
@ -2,9 +2,6 @@
|
||||
const DEPENDENCY_KEYS = ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies']
|
||||
const VERSION_PREFIXES = ['^', '~']
|
||||
|
||||
// Generate regex pattern for dependency keys
|
||||
const DEPENDENCY_KEYS_PATTERN = `^(${DEPENDENCY_KEYS.join('|')})$`
|
||||
|
||||
/** @type {import('eslint').Rule.RuleModule} */
|
||||
export default {
|
||||
meta: {
|
||||
@ -21,8 +18,17 @@ export default {
|
||||
return {}
|
||||
|
||||
return {
|
||||
// Check each property in dependency sections
|
||||
[`Property[key.value=/${DEPENDENCY_KEYS_PATTERN}/] > ObjectExpression > Property`](node) {
|
||||
// Check each property that could be a dependency section
|
||||
'Property > ObjectExpression > Property'(node) {
|
||||
// Check if the parent property is one of the dependency keys
|
||||
const parentProperty = node.parent?.parent
|
||||
if (!parentProperty || parentProperty.type !== 'Property')
|
||||
return
|
||||
|
||||
const parentKey = parentProperty.key?.value || parentProperty.key?.name
|
||||
if (!DEPENDENCY_KEYS.includes(parentKey))
|
||||
return
|
||||
|
||||
const versionNode = node.value
|
||||
|
||||
// Check if the version value starts with any forbidden prefix
|
||||
|
||||
Reference in New Issue
Block a user