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

fix(linter): improve no-zero-fractions rule for member expressions and scientific notation #4793

Merged
merged 14 commits into from
Aug 16, 2024

Commits on Aug 10, 2024

  1. fix(linter): improve no-zero-fractions rule for member expressions

    - Added a check for parent nodes that are MemberExpressions
    - If a parent node is a MemberExpression, the fixed number is now wrapped in
      parentheses to maintain correct syntax
    cblh committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    fac6271 View commit details
    Browse the repository at this point in the history
  2. feat(linter): improve no-zero-fractions rule

    This commit enhances the no-zero-fractions rule in the unicorn linter:
    
    - Add support for scientific notation (e.g., 1e10, 1.e10)
    - Improve handling of member expressions
    - Introduce is_decimal_integer utility function
    - Update test cases and snapshots to reflect new behavior
    - Fix various edge cases in number formatting
    
    These changes make the rule more robust and consistent with the original
    ESLint implementation, especially for scientific notation and member
    expressions.
    cblh committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    d518230 View commit details
    Browse the repository at this point in the history
  3. chore(linter): Refactor NoZeroFractions rule for improved formattin…

    …g and clarity
    
    - Simplified the condition that checks for decimal integers within member expressions by removing unnecessary parentheses around the formatted string.
    - Updated string formatting in `format_raw` function to use the shorthand `{variable}` syntax instead of `{}` with positional arguments.
    cblh committed Aug 10, 2024
    Configuration menu
    Copy the full SHA
    5e4996b View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2024

  1. fix(linter): improve no-zero-fractions rule

    - Handle special cases where a space is needed after certain keywords
      (return, throw, typeof) to prevent the number from being interpreted
      as a property access
    - Add tests for these special cases
    - Update existing tests to cover more scenarios
    cblh committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    44d9fb4 View commit details
    Browse the repository at this point in the history
  2. fix(linter): add 'void' keyword support to no-zero-fractions rule

    - Include 'void' in the list of keywords that require a space before
      the number to prevent misinterpretation as property access
    - Add test cases for 'void' keyword scenarios
    cblh committed Aug 12, 2024
    Configuration menu
    Copy the full SHA
    de2cf76 View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2024

  1. refactor(linter): remove is_decimal_integer utility and simplify `n…

    …o-zero-fractions` rule
    
    - Removed the `is_decimal_integer` function and related `numeric.rs` utility, as it was no longer necessary.
    - Simplified the `no-zero-fractions` rule by directly checking for non-dangling dots instead of using the removed utility.
    - Updated the logic for fixing number formatting to remove redundant checks.
    cblh committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    783a8b1 View commit details
    Browse the repository at this point in the history
  2. chore(linter): fmt

    cblh committed Aug 13, 2024
    Configuration menu
    Copy the full SHA
    2c81c45 View commit details
    Browse the repository at this point in the history

Commits on Aug 14, 2024

  1. fix(unicorn/no-zero-fractions): improve handling of member expression…

    …s and decimal integers
    
    - Refactored logic in the `NoZeroFractions` rule to ensure proper handling of cases where the numeric value is a decimal integer and part of a member expression.
    - Added a clone of the format string to avoid mutating the original `fmt`.
    - Introduced checks for `is_decimal_integer` and `is_member_expression` to better control the formatting of the fixed value.
    - Updated test cases to cover additional scenarios, including fixing fractional values like `1.010.toFixed(2)` to `1.01.toFixed(2)`.
    cblh committed Aug 14, 2024
    Configuration menu
    Copy the full SHA
    599af69 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a35fcde View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    bec8195 View commit details
    Browse the repository at this point in the history

Commits on Aug 15, 2024

  1. Configuration menu
    Copy the full SHA
    5edbb19 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2024

  1. Configuration menu
    Copy the full SHA
    39e49d7 View commit details
    Browse the repository at this point in the history
  2. feat(linter): Enhance no_zero_fractions rule handling

    - Add TODO for more complex token checks and semicolon handling
    - Prepare for special keyword cases requiring space after fixed value
    cblh committed Aug 16, 2024
    Configuration menu
    Copy the full SHA
    bfa2fb5 View commit details
    Browse the repository at this point in the history
  3. feat(linter): Enhance no_zero_fractions rule handling

    - Add TODO for more complex token checks and
    cblh committed Aug 16, 2024
    Configuration menu
    Copy the full SHA
    4d4acd2 View commit details
    Browse the repository at this point in the history