Removed optional chaining where possible and migrated to the auto generated lint index.
MODIFY
packages/@romejs/diagnostics/categories.ts
packages/@romejs/diagnostics/categories.ts
@@ -99,6 +99,7 @@ type LintDiagnosticCategory =
| 'lint/emptyBlocks'
| 'lint/getterReturn'
| 'lint/inconsiderateLanguage'
+ | 'lint/jsxKey'
| 'lint/jsxNoCommentText'
| 'lint/noArguments'
| 'lint/noAsyncPromiseExecutor'

MODIFY
packages/@romejs/diagnostics/descriptions.ts
packages/@romejs/diagnostics/descriptions.ts
@@ -355,7 +355,7 @@ export const descriptions = createMessages({
message: 'Comments inside children should be placed in braces',
},
REACT_JSX_KEY: (origin: string) => ({
- category: 'lint/react/jsxKey',
+ category: 'lint/jsxKey',
message: markup`Missing the "key" prop for element in ${origin}`,
}),
UNSAFE_NEGATION: {

MODIFY
packages/@romejs/js-compiler/lint/rules/index.ts
packages/@romejs/js-compiler/lint/rules/index.ts
*/
// EVERYTHING BELOW IS AUTOGENERATED. SEE SCRIPTS FOLDER FOR UPDATE SCRIPTS
+
import camelCase from './regular/camelCase';
import caseSingleStatement from './regular/caseSingleStatement';
import defaultExportSameBasename from './regular/defaultExportSameBasename';
@@ -14,6 +15,7 @@ import duplicateImportSource from './regular/duplicateImportSource';
import emptyBlocks from './regular/emptyBlocks';
import getterReturn from './regular/getterReturn';
import inconsiderateLanguage from './regular/inconsiderateLanguage';
+import jsxKey from './react/jsxKey';
import jsxNoCommentText from './react/jsxNoCommentText';
import noArguments from './regular/noArguments';
import noAsyncPromiseExecutor from './regular/noAsyncPromiseExecutor';
@@ -62,6 +64,7 @@ export const lintTransforms = [
emptyBlocks,
getterReturn,
inconsiderateLanguage,
+ jsxKey,
jsxNoCommentText,
noArguments,
noAsyncPromiseExecutor,

MODIFY
packages/@romejs/js-compiler/lint/rules/react/jsxKey.test.ts
packages/@romejs/js-compiler/lint/rules/react/jsxKey.test.ts
import {test} from 'rome';
import {dedent} from '@romejs/string-utils';
-import {testLintMultiple} from '../../testHelpers';
+import {testLintMultiple} from '../testHelpers';
test(
'jsx key',
@@ -58,7 +58,7 @@ test(
`,
),
],
- {category: 'lint/react/jsxKey'},
+ {category: 'lint/jsxKey'},
);
},
);

MODIFY
packages/@romejs/js-compiler/lint/rules/react/jsxKey.ts
packages/@romejs/js-compiler/lint/rules/react/jsxKey.ts
@@ -33,16 +33,16 @@ export default {
// Array.prototype.map
if (
node.type === 'CallExpression' &&
- node.callee?.type === 'MemberExpression' &&
- (node.callee.property?.value)?.type === 'Identifier' &&
+ node.callee.type === 'MemberExpression' &&
+ node.callee.property.value.type === 'Identifier' &&
node.callee.property.value.name === 'map'
) {
const fn = node.arguments[0];
// Short hand arrow function
if (
- fn?.type === 'ArrowFunctionExpression' &&
- fn.body?.type === 'JSXElement' &&
+ fn.type === 'ArrowFunctionExpression' &&
+ fn.body.type === 'JSXElement' &&
!containsKeyAttr(fn.body)
) {
context.addNodeDiagnostic(
@@ -56,7 +56,7 @@ export default {
fn &&
(fn.type === 'FunctionExpression' ||
fn.type === 'ArrowFunctionExpression') &&
- fn.body?.type === 'BlockStatement'
+ fn.body.type === 'BlockStatement'
) {
fn.body.body.forEach((statement) => {
if (

Removed optional chaining where possible and migrated to the auto generated lint index.