Skip to content

fix: state how the alphabetical function compares elements - #27

Open
joostfarla wants to merge 1 commit into
mainfrom
alphabetical-order
Open

joostfarla wants to merge 1 commit into
mainfrom
alphabetical-order

Conversation

@joostfarla

Copy link
Copy Markdown
Member

The requirement for alphabetical said numbers are compared by value and two values of different types count as in order. That did not match Spectral and OpenLint. The section now states the comparison in full.

  • A table says when a compared value is out of order with the next one, for every pair of types. A boolean, null, an array, or an object is always out of order.
  • A numeric string is defined by the StringNumericLiteral grammar of ECMAScript, with a link to the exact production.
  • String order follows the Unicode Collation Algorithm and the locale data of CLDR, for the locale the linter runs under. The reference to ECMA-402 is removed, and no method of a programming language is named.
  • The requirement covers values with fewer than two elements, keyedBy on an element that is not an object or lacks the property, and says that the function fails with one problem.
  • A note replaces the inline issue on locale-dependent order.

Two statements describe intended behavior that Spectral and OpenLint do not have yet. No test covers them until the toolbox is fixed:

  • A number is out of order before any smaller number. Both linters only report a difference of 1 or more, so [1.5, 1] passes.
  • An array is not an object under keyedBy. Both linters accept an index or length as the property of an array.

Seven tests are added, and two existing ones are adjusted: alphabetical-numbers gains a pair of equal numbers, and the purpose of alphabetical-case no longer names a method.

Refs #13

The requirement said numbers are compared by value and two values of
different types count as in order. That did not match Spectral and
OpenLint. The section now states the comparison in full.

A table says when a compared value is out of order with the next one,
for every pair of types. A numeric string is defined by the
StringNumericLiteral grammar of ECMAScript. String order follows the
Unicode Collation Algorithm and the locale data of CLDR, and the
reference to ECMA-402 is removed. The requirement covers values with
fewer than two elements and keyedBy on an element that is not an
object. A note replaces the inline issue on locale-dependent order.

Two statements describe intended behavior that the linters do not have
yet, and no test covers them: a number is out of order before any
smaller number, where both linters only report a difference of 1 or
more, and an array is not an object under keyedBy.

Seven tests are added, and alphabetical-numbers and alphabetical-case
are adjusted.

Refs #13

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant