Fix emptyBlocks to detect empty alternate
ADD
packages/@romejs/js-compiler/lint/rules/emptyBlocks.test.ts
+/**
+ * Copyright (c) Facebook, Inc. and its affiliates.
+ *
+ * This source code is licensed under the MIT license found in the
+ * LICENSE file in the root directory of this source tree.
+ */
+
+import {test} from 'rome';
+import {testLintMultiple} from '../testHelpers';
+import {dedent} from '@romejs/string-utils';
+
+test(
+ 'empty blocks',
+ async (t) => {
+ await testLintMultiple(
+ t,
+ [
+ // VALID
+ dedent`
+ if (foo) foo;
+ `,
+ dedent`
+ if (foo) {
+ foo;
+ }
+ `,
+ dedent`
+ if (foo) {
+ // empty
+ }
+ `,
+ // INVALID
+ dedent`
+ if (foo) {}
+ `,
+ dedent`
+ if (foo) {
+ // foo;
+ } else {}
+ `,
+ ],
+ {category: 'lint/emptyBlocks'},
+ );
+ },
+);

MODIFY
packages/@romejs/js-compiler/lint/rules/emptyBlocks.ts
packages/@romejs/js-compiler/lint/rules/emptyBlocks.ts
@@ -38,6 +38,13 @@ export default {
descriptions.LINT.EMPTY_BLOCKS,
);
}
+
+ if (node.alternate !== undefined && isEmpty(node.alternate)) {
+ context.addNodeDiagnostic(
+ node.alternate,
+ descriptions.LINT.EMPTY_BLOCKS,
+ );
+ }
}
return node;

Fix emptyBlocks to detect empty alternate