Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💅 matching $ unsupported in naming convention due to Anchor assumption #5173

Open
1 task done
jstephens986 opened this issue Feb 21, 2025 · 7 comments
Open
1 task done
Labels
A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@jstephens986
Copy link

jstephens986 commented Feb 21, 2025

Environment information

CLI:
  Version:                      1.9.4
  Color support:                true

Platform:
  CPU Architecture:             aarch64
  OS:                           macos

Environment:
  BIOME_LOG_PATH:               unset
  BIOME_LOG_PREFIX_NAME:        unset
  BIOME_CONFIG_PATH:            unset
  NO_COLOR:                     unset
  TERM:                         "xterm-256color"
  JS_RUNTIME_VERSION:           "v20.11.1"
  JS_RUNTIME_NAME:              "node"
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Error:                        Anchors `^` and `$` are not supported. They are implciitly present.
  Status:                       Loaded with errors
  Formatter disabled:           false
  Linter disabled:              false
  Organize imports disabled:    false
  VCS disabled:                 false

Linter:
  JavaScript enabled:           true
  JSON enabled:                 true
  CSS enabled:                  true
  GraphQL enabled:              false
  Recommended:                  true
  All:                          false
  Enabled rules:
  performance/noDelete
  suspicious/noCatchAssign
  suspicious/noUnsafeNegation
  complexity/useLiteralKeys
  suspicious/noEmptyBlock
  style/useImportType
  complexity/noMultipleSpacesInRegularExpressionLiterals
  a11y/useValidLang
  complexity/noUselessEmptyExport
  suspicious/useNamespaceKeyword
  suspicious/useValidTypeof
  a11y/useValidAriaRole
  correctness/noConstantCondition
  a11y/useAriaActivedescendantWithTabindex
  suspicious/noAssignInExpressions
  style/useDefaultParameterLast
  complexity/noEmptyTypeParameters
  correctness/noConstructorReturn
  style/useSelfClosingElements
  suspicious/noDuplicateParameters
  suspicious/noDuplicateSelectorsKeyframeBlock
  correctness/noUnknownProperty
  style/useTemplate
  correctness/noUnusedLabels
  complexity/noUselessTernary
  correctness/noUnreachableSuper
  suspicious/noCompareNegZero
  suspicious/noExplicitAny
  correctness/noSwitchDeclarations
  a11y/noAutofocus
  correctness/noUnsafeOptionalChaining
  correctness/noConstAssign
  suspicious/noControlCharactersInRegex
  complexity/noUselessTypeConstraint
  style/noVar
  suspicious/noDoubleEquals
  suspicious/noRedundantUseStrict
  style/useLiteralEnumMembers
  suspicious/noGlobalIsNan
  suspicious/noEmptyInterface
  suspicious/noConstEnum
  suspicious/noMisleadingCharacterClass
  correctness/noPrecisionLoss
  a11y/noLabelWithoutControl
  suspicious/noRedeclare
  correctness/noStringCaseMismatch
  correctness/noSetterReturn
  correctness/noInvalidConstructorSuper
  suspicious/noImplicitAnyLet
  suspicious/noFallthroughSwitchClause
  suspicious/noUnsafeDeclarationMerging
  complexity/noUselessThisAlias
  correctness/noUnreachable
  a11y/useKeyWithClickEvents
  suspicious/noDuplicateObjectKeys
  complexity/noThisInStatic
  complexity/useOptionalChain
  correctness/noInnerDeclarations
  style/noParameterAssign
  suspicious/noDuplicateCase
  a11y/useValidAnchor
  complexity/useRegexLiterals
  correctness/noSelfAssign
  correctness/noInvalidBuiltinInstantiation
  style/noUselessElse
  style/useShorthandFunctionType
  suspicious/noEmptyBlockStatements
  correctness/noInvalidDirectionInLinearGradient
  suspicious/noImportantInKeyframe
  a11y/useMediaCaption
  complexity/noUselessLabel
  complexity/noUselessCatch
  correctness/noUnsafeFinally
  a11y/useAriaPropsForRole
  correctness/noNonoctalDecimalEscape
  style/useEnumInitializers
  a11y/useHtmlLang
  suspicious/noDuplicateTestHooks
  complexity/noStaticOnlyClass
  style/useWhile
  style/noInferrableTypes
  style/useNumericLiterals
  a11y/noNoninteractiveTabindex
  complexity/useSimpleNumberKeys
  correctness/useYield
  a11y/noInteractiveElementToNoninteractiveRole
  suspicious/noImportAssign
  correctness/noUnnecessaryContinue
  suspicious/noApproximativeNumericConstant
  suspicious/noLabelVar
  suspicious/useDefaultSwitchClauseLast
  correctness/noGlobalObjectCalls
  a11y/useAltText
  correctness/noEmptyCharacterClassInRegex
  correctness/noUnknownUnit
  suspicious/noSparseArray
  a11y/useIframeTitle
  complexity/noBannedTypes
  a11y/noSvgWithoutTitle
  correctness/noVoidElementsWithChildren
  style/useAsConstAssertion
  correctness/useJsxKeyInIterable
  style/useExportType
  complexity/noUselessLoneBlockStatements
  style/noArguments
  suspicious/noDebugger
  a11y/useValidAriaValues
  suspicious/noCommentText
  a11y/useFocusableInteractive
  correctness/noUnmatchableAnbSelector
  suspicious/noGlobalAssign
  suspicious/noDuplicateJsxProps
  suspicious/noMisleadingInstantiator
  a11y/noPositiveTabindex
  correctness/noEmptyPattern
  complexity/noExcessiveNestedTestSuites
  security/noDangerouslySetInnerHtmlWithChildren
  a11y/useKeyWithMouseEvents
  style/useNamingConvention
  suspicious/noExtraNonNullAssertion
  correctness/noRenderReturnValue
  correctness/useExhaustiveDependencies
  security/noGlobalEval
  style/noNonNullAssertion
  a11y/noRedundantRoles
  complexity/useFlatMap
  correctness/useIsNan
  correctness/noUnusedVariables
  style/useConst
  suspicious/noGlobalIsFinite
  suspicious/noSelfCompare
  suspicious/noAsyncPromiseExecutor
  suspicious/noDuplicateFontNames
  suspicious/noThenProperty
  suspicious/useGetterReturn
  security/noDangerouslySetInnerHtml
  a11y/noDistractingElements
  suspicious/noArrayIndexKey
  complexity/noWith
  suspicious/noShorthandPropertyOverrides
  suspicious/noDuplicateClassMembers
  complexity/noExtraBooleanCast
  performance/noAccumulatingSpread
  a11y/useValidAriaProps
  a11y/noRedundantAlt
  correctness/noChildrenProp
  correctness/noUnknownFunction
  correctness/noInvalidPositionAtImportRule
  suspicious/noConfusingLabels
  suspicious/noPrototypeBuiltins
  suspicious/noConfusingVoidType
  suspicious/noFocusedTests
  a11y/useButtonType
  a11y/useSemanticElements
  a11y/noAriaUnsupportedElements
  correctness/noInvalidGridAreas
  correctness/noFlatMapIdentity
  suspicious/noSuspiciousSemicolonInJsx
  a11y/noBlankTarget
  a11y/useHeadingContent
  correctness/useValidForDirection
  correctness/noVoidTypeReturn
  correctness/noInvalidUseBeforeDeclaration
  a11y/noAriaHiddenOnFocusable
  a11y/useGenericFontNames
  correctness/noUnknownMediaFeatureName
  a11y/useAnchorContent
  complexity/noUselessRename
  style/useNumberNamespace
  complexity/noUselessConstructor
  a11y/noAccessKey
  style/useExponentiationOperator
  style/noUnusedTemplateLiteral
  complexity/noUselessSwitchCase
  correctness/noUndeclaredVariables
  style/useSingleVarDeclarator
  suspicious/noExportsInTest
  a11y/noNoninteractiveElementToInteractiveRole
  style/noCommaOperator
  suspicious/noDuplicateAtImportRules
  suspicious/useIsArray
  correctness/noNewSymbol
  a11y/noHeaderScope
  suspicious/noMisrefactoredShorthandAssign
  complexity/noUselessFragments
  complexity/noForEach
  suspicious/noClassAssign
  suspicious/noFunctionAssign

Workspace:
  Open Documents:               0

Rule name

linter/style/useNamingConvention

Playground link

https://biomejs.dev/playground/?code=YwBvAG4AcwB0ACAAdABhAGIAbABlAEMAbwBsAHUAbQBuAFcAaQBkAHQAaABTAHQAeQBsAGUAcwAgAD0AIABjAHMAcwA8AHsACgAgACAAJABjAG8AbAB1AG0AbgBTAGkAegBlAD8AOgAgAG4AdQBtAGIAZQByAAoAIAAgACQAdABhAGIAbABlAFMAaQB6AGUAOgAgAG4AdQBtAGIAZQByAAoAfQA%2BAAoACgAgACAALwAvACAAIAAgACAAIAAgACAAIgB1AHMAZQBOAGEAbQBpAG4AZwBDAG8AbgB2AGUAbgB0AGkAbwBuACIAOgAgAHsACgAgACAALwAvACAAIAAgACAAIAAgACAAIAAgACIAbABlAHYAZQBsACIAOgAgACIAdwBhAHIAbgAiACwACgAgACAALwAvACAAIAAgACAAIAAgACAAIAAgACIAbwBwAHQAaQBvAG4AcwAiADoAIAB7AAoAIAAgAC8ALwAgACAAIAAgACAAIAAgACAAIAAgACAAIgBzAHQAcgBpAGMAdABDAGEAcwBlACIAOgAgAGYAYQBsAHMAZQAsAAoAIAAgAC8ALwAgACAAIAAgACAAIAAgACAAIAAgACAAIgBjAG8AbgB2AGUAbgB0AGkAbwBuAHMAIgA6ACAAWwAKACAAIAAvAC8AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAB7AAoAIAAgAC8ALwAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAiAHMAZQBsAGUAYwB0AG8AcgAiADoAIAB7ACAAIgBrAGkAbgBkACIAOgAgACIAdAB5AHAAZQBQAHIAbwBwAGUAcgB0AHkAIgAgAH0ALAAKACAAIAAvAC8AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIgBtAGEAdABjAGgAIgA6ACAAIgAoAFwAXAAkACkAPwAoAF8AKQA%2FAFsAYQAtAHoAQQAtAFoAXwAwAC0AOQBdACsAIgAKACAAIAAvAC8AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAB9ACwACgAgACAALwAvACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAewAKACAAIAAvAC8AIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIgBzAGUAbABlAGMAdABvAHIAIgA6ACAAewAgACIAawBpAG4AZAAiADoAIAAiAG8AYgBqAGUAYwB0AEwAaQB0AGUAcgBhAGwAUAByAG8AcABlAHIAdAB5ACIAIAB9ACwACgAgACAALwAvACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAAgACIAbQBhAHQAYwBoACIAOgAgACIAKABcAFwAJAApAD8AKABfACkAPwBbAGEALQB6AEEALQBaAF8AMAAtADkAXQArACIACgAgACAALwAvACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAfQAsAAoAIAAgAC8ALwAgACAAIAAgACAAIAAgACAAIAAgACAAXQAKACAAIAAvAC8AIAAgACAAIAAgACAAIAAgACAAfQAKACAAIAAvAC8AIAAgACAAIAAgACAAIAB9AA%3D%3D

Expected result

I am encountering an issue with styled-components where certain properties can be prefixed with $ to make them transient. However, when attempting to create a namingConvention rule to target these properties, the Biomejs configuration becomes invalid. This appears to be due to an incorrect assumption that all $ characters are expression anchors in the Biomejs config.

It is expected that tailing $ only be counted as an anchors.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@jstephens986 jstephens986 added the S-Needs triage Status: this issue needs to be triaged label Feb 21, 2025
@dyc3
Copy link
Contributor

dyc3 commented Feb 21, 2025

Have you tried escaping the $ like this? \$

@jstephens986
Copy link
Author

Have you tried escaping the $ like this? \$

Yes I have tried to escape using \\$ but biome will still throw a configuration error thinking it is an expression anchor.

I have also tried to get around it fully by using (\u0024)?, it resolves the issue with it being an invalid config but the character is just fully filtered out resulting in ()?(_)?...

@dyc3
Copy link
Contributor

dyc3 commented Feb 22, 2025

No, I meant with only one \

@jstephens986
Copy link
Author

jstephens986 commented Feb 22, 2025

No, I meant with only one \

Yeah that is resulting in an Invalid escape sequence error.

Valid escape sequences are: `\\`, `\/`, `/"`, `\b\`, `\f`, `\n`, `\r`, `\t` or any unicode escape sequence `\uXXXX` where X is hexedecimal number

@dyc3
Copy link
Contributor

dyc3 commented Feb 22, 2025

Interesting. There must be something going wrong because we explicitly allow $ to be escaped here:

But the diagnostic you're seeing seeing seems to becoming from the JSON parser, not the rule or RestrictedRegex.

@dyc3 dyc3 added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug labels Feb 22, 2025
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Feb 22, 2025
@dyc3 dyc3 added A-Parser Area: parser S-Needs triage Status: this issue needs to be triaged labels Feb 22, 2025
@github-actions github-actions bot removed the S-Needs triage Status: this issue needs to be triaged label Feb 22, 2025
@ematipico
Copy link
Member

@jstephens986 can you please update the playground:

  • create another file (you need to go in multi file mode)
  • call it biome.json
  • paste there the configuration you're using

So we can reproduce the diagnostics you're seeing

@ematipico
Copy link
Member

cc @Conaclos

Maybe he can help us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

3 participants