Add lint/noArguments rule
MODIFY
packages/@romejs/diagnostics/categories.ts
packages/@romejs/diagnostics/categories.ts
@@ -29,6 +29,7 @@ export type DiagnosticCategory =
| 'lint/noVar'
| 'lint/emptyBlocks'
| 'lint/getterReturn'
+ | 'lint/noArguments'
| 'lint/noAsyncPromiseExecutor'
| 'lint/noCompareNegZero'
| 'lint/noCondAssign'

MODIFY
packages/@romejs/diagnostics/descriptions.ts
packages/@romejs/diagnostics/descriptions.ts
@@ -416,6 +416,11 @@ export const descriptions = createMessages({
message: 'Empty block',
},
+ NO_ARGUMENTS: {
+ category: 'lint/noArguments',
+ message: 'Use the rest parameters instead of \'arguments\'',
+ },
+
DUPLICATE_REGEX_GROUP_NAME: (
name: string,
locations: Array<undefined | DiagnosticLocation>,

MODIFY
packages/@romejs/js-compiler/transforms/lint/index.ts
packages/@romejs/js-compiler/transforms/lint/index.ts
@@ -10,6 +10,7 @@ import defaultExportSameBasename from './defaultExportSameBasename';
import duplicateImportSource from './duplicateImportSource';
import emptyBlocks from './emptyBlocks';
import getterReturn from './getterReturn';
+import noArguments from './noArguments';
import noAsyncPromiseExecutor from './noAsyncPromiseExecutor';
import noCompareNegZero from './noCompareNegZero';
import noCondAssign from './noCondAssign';
@@ -46,6 +47,7 @@ export const lintTransforms = [
duplicateImportSource,
emptyBlocks,
getterReturn,
+ noArguments,
noAsyncPromiseExecutor,
noCompareNegZero,
noCondAssign,

ADD
packages/@romejs/js-compiler/transforms/lint/noArguments.test.md
+# `noArguments.test.ts`
+
+**DO NOT MODIFY**. This file has been autogenerated. Run `rome test packages/@romejs/js-compiler/transforms/lint/noArguments.test.ts --update-snapshots` to update.
+
+## `no arguments`
+
+### `0`
+
+```javascript
+Object {
+ src: '\n function f() {\n console.log(arguments);\n }\n f();\n '
+ suppressions: Array []
+ diagnostics: Array [
+ Object {
+ origins: Array [Object {category: 'lint'}]
+ description: Object {
+ category: 'lint/noArguments'
+ message: PARTIAL_BLESSED_DIAGNOSTIC_MESSAGE {value: 'Use the rest parameters instead of \'arguments\''}
+ }
+ location: Object {
+ filename: 'unknown'
+ language: 'js'
+ mtime: undefined
+ sourceType: 'module'
+ end: Object {
+ column: 27
+ index: 47
+ line: 3
+ }
+ start: Object {
+ column: 18
+ index: 38
+ line: 3
+ }
+ }
+ }
+ ]
+}
+```
+
+### `1`
+
+```javascript
+Object {
+ src: '\n (function () {\n console.log(arguments);\n })();\n '
+ suppressions: Array []
+ diagnostics: Array [
+ Object {
+ origins: Array [Object {category: 'lint'}]
+ description: Object {
+ category: 'lint/noArguments'
+ message: PARTIAL_BLESSED_DIAGNOSTIC_MESSAGE {value: 'Use the rest parameters instead of \'arguments\''}
+ }
+ location: Object {
+ filename: 'unknown'
+ language: 'js'
+ mtime: undefined
+ sourceType: 'module'
+ end: Object {
+ column: 27
+ index: 47
+ line: 3
+ }
+ start: Object {
+ column: 18
+ index: 38
+ line: 3
+ }
+ }
+ }
+ ]
+}
+```
+
+### `2`
+
+```javascript
+Object {
+ src: '\n class C {\n fn() {\n console.log(arguments);\n }\n }\n (new C()).fn();\n '
+ suppressions: Array []
+ diagnostics: Array [
+ Object {
+ origins: Array [Object {category: 'lint'}]
+ description: Object {
+ category: 'lint/noArguments'
+ message: PARTIAL_BLESSED_DIAGNOSTIC_MESSAGE {value: 'Use the rest parameters instead of \'arguments\''}
+ }
+ location: Object {
+ filename: 'unknown'
+ language: 'js'
+ mtime: undefined
+ sourceType: 'module'
+ end: Object {
+ column: 29
+ index: 57
+ line: 4
+ }
+ start: Object {
+ column: 20
+ index: 48
+ line: 4
+ }
+ }
+ }
+ ]
+}
+```
+
+### `3`
+
+```javascript
+Object {
+ src: '\n const o = {\n fn() {\n console.log(arguments);\n }\n };\n o.fn();\n '
+ suppressions: Array []
+ diagnostics: Array [
+ Object {
+ origins: Array [Object {category: 'lint'}]
+ description: Object {
+ category: 'lint/noArguments'
+ message: PARTIAL_BLESSED_DIAGNOSTIC_MESSAGE {value: 'Use the rest parameters instead of \'arguments\''}
+ }
+ location: Object {
+ filename: 'unknown'
+ language: 'js'
+ mtime: undefined
+ sourceType: 'module'
+ end: Object {
+ column: 29
+ index: 59
+ line: 4
+ }
+ start: Object {
+ column: 20
+ index: 50
+ line: 4
+ }
+ }
+ }
+ ]
+}
+```

ADD
packages/@romejs/js-compiler/transforms/lint/noArguments.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 '@romejs/test';
+import {testLint} from '../../api/lint.test';
+
+test('no arguments', async (t) => {
+ t.snapshot(await testLint(`
+ function f() {
+ console.log(arguments);
+ }
+ f();
+ `));
+
+ t.snapshot(await testLint(`
+ (function () {
+ console.log(arguments);
+ })();
+ `));
+
+ t.snapshot(await testLint(`
+ class C {
+ fn() {
+ console.log(arguments);
+ }
+ }
+ (new C()).fn();
+ `));
+
+ t.snapshot(await testLint(`
+ const o = {
+ fn() {
+ console.log(arguments);
+ }
+ };
+ o.fn();
+ `));
+});

ADD
packages/@romejs/js-compiler/transforms/lint/noArguments.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 {AnyNode} from '@romejs/js-ast';
+import {Path} from '@romejs/js-compiler';
+import {descriptions} from '@romejs/diagnostics';
+
+export default {
+ name: 'noArguments',
+ enter(path: Path): AnyNode {
+ const {node, scope} = path;
+
+ if (node.type === 'ReferenceIdentifier' && node.name === 'arguments') {
+ const args = scope.getBinding('arguments');
+ if (args && args.kind === 'arguments') {
+ path.context.addNodeDiagnostic(node, descriptions.LINT.NO_ARGUMENTS);
+ }
+ }
+
+ return node;
+ },
+};

Add lint/noArguments rule