Tools: jsxA11Y casing autogenerated in packages/@romejs/js-compiler/lint/rules/index.ts

Created on 17 May 2020  路  3Comments  路  Source: rome/tools

Description:

when I run node scripts/lint/add.cjs aRule react, the auto generated file keeps changing the spelling of the rules prefixed with node jsxA11y. Master has capital Y jsxA11Y which doesn't match the lowercase y in the pathname. I'm for matching the pathname, so if it's capital Y in pathname, then same for the rule name, and if lowercase Y, then match in pathname and rulename.

Steps To Reproduce

  1. run node scripts/lint/add.cjs aRule react
  2. check packages/@romejs/js-compiler/lint/rules/index.ts

Screen Shot 2020-05-17 at 12 36 56 PM

Expected Results

The updated file shouldn't affect those lines

confirmed

Most helpful comment

I'm actually working on a slight reorganization of our lint rules so that they properly align with their upstream plugin groupings. To @VictorHom's point, we have jsx-a11y rules in the react group, etc.

Regardless of the updated grouping, I still think we should be camel casing generated filenames in using the same logic as the linter like @sebmck suggested. Addressed in #470.

All 3 comments

What's happening is that when lint --save is ran it's automatically renaming those variables to "correct camelcase". There's not really a way for us to correctly infer that when "a11y" is one word.

We should update scripts/lint/add.cjs to properly convert the rule name to the camelcase format we expect. Might be weird since the camelcase logic is a bit complicated. See toVariableCamelCase in packages/@romejs/js-compiler/lint/rules/regular/camelCase.ts that then uses packages/@romejs/string-utils/toCamelCase.ts.

alternatively, we can put all jsx_a11y into it's own directory at the level of react and regular

That way contributors don't have to keep adding that prefix which I had to think about as I was naming (jsxA11y , or jsxA11Y).

Also would make it easier to read the names of the rules because seeing the prefix just makes it harder to find the rule you're looking for sometimes if you're just trying to read the file names.

I'm actually working on a slight reorganization of our lint rules so that they properly align with their upstream plugin groupings. To @VictorHom's point, we have jsx-a11y rules in the react group, etc.

Regardless of the updated grouping, I still think we should be camel casing generated filenames in using the same logic as the linter like @sebmck suggested. Addressed in #470.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sebmck picture sebmck  路  5Comments

sebmck picture sebmck  路  5Comments

sebmck picture sebmck  路  3Comments

yamadayuki picture yamadayuki  路  3Comments

sebmck picture sebmck  路  4Comments