add tests
also modified testLint to accept ts/flow syntax
MODIFY
packages/@romejs/js-compiler/api/lint.test.ts
packages/@romejs/js-compiler/api/lint.test.ts
@@ -13,12 +13,13 @@ import lint from './lint';
import {parseJS} from '@romejs/js-parser';
import {createUnknownFilePath} from '@romejs/path';
import {DEFAULT_PROJECT_CONFIG} from '@romejs/project';
-import {ConstSourceType} from '@romejs/js-ast';
+import {ConstSourceType, ConstProgramSyntax} from '@romejs/js-ast';
export async function testLint(
input: string,
format: boolean = false,
sourceType: ConstSourceType = 'module',
+ syntax?: Array<ConstProgramSyntax>,
) {
return await lint({
options: {},
@@ -27,6 +28,7 @@ export async function testLint(
input,
sourceType,
path: createUnknownFilePath('unknown'),
+ syntax,
}),
sourceText: input,
project: {

ADD
packages/@romejs/js-compiler/transforms/lint/noExplicitAny.test.md
+# `noExplicitAny.test.ts`
+
+**DO NOT MODIFY**. This file has been autogenerated. Run `rome test packages/@romejs/js-compiler/transforms/lint/noExplicitAny.test.ts --update-snapshots` to update.
+
+## `no explicit any`
+
+### `0`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 14
+ index: 14
+ line: 1
+ }
+ start: Object {
+ column: 11
+ index: 11
+ line: 1
+ }
+ }
+]
+```
+
+### `1`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 15
+ index: 15
+ line: 1
+ }
+ start: Object {
+ column: 12
+ index: 12
+ line: 1
+ }
+ }
+]
+```
+
+### `2`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 21
+ index: 21
+ line: 1
+ }
+ start: Object {
+ column: 18
+ index: 18
+ line: 1
+ }
+ }
+]
+```
+
+### `3`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 21
+ index: 21
+ line: 1
+ }
+ start: Object {
+ column: 18
+ index: 18
+ line: 1
+ }
+ }
+]
+```
+
+### `4`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 21
+ index: 21
+ line: 1
+ }
+ start: Object {
+ column: 18
+ index: 18
+ line: 1
+ }
+ }
+]
+```
+
+### `5`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 27
+ index: 27
+ line: 1
+ }
+ start: Object {
+ column: 24
+ index: 24
+ line: 1
+ }
+ }
+]
+```
+
+### `6`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 33
+ index: 33
+ line: 1
+ }
+ start: Object {
+ column: 30
+ index: 30
+ line: 1
+ }
+ }
+]
+```
+
+### `7`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 31
+ index: 31
+ line: 1
+ }
+ start: Object {
+ column: 28
+ index: 28
+ line: 1
+ }
+ }
+]
+```
+
+### `8`
+
+```javascript
+Array [
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 31
+ index: 31
+ line: 1
+ }
+ start: Object {
+ column: 28
+ index: 28
+ line: 1
+ }
+ }
+ Object {
+ category: 'lint/noExplicitAny'
+ filename: 'unknown'
+ language: 'js'
+ message: 'Unexpected any. Specify a different type.'
+ mtime: undefined
+ sourceType: 'module'
+ origins: Array [Object {category: 'lint'}]
+ end: Object {
+ column: 44
+ index: 44
+ line: 1
+ }
+ start: Object {
+ column: 41
+ index: 41
+ line: 1
+ }
+ }
+]
+```

ADD
packages/@romejs/js-compiler/transforms/lint/noExplicitAny.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 explicit any', async t => {
+ const validTestCases = [
+ 'const age: number = 17;age;',
+ 'const ages: number[] = [17];ages;',
+ 'const ages: Array<number> = [17];ages;',
+ 'function greet(): string {};greet();',
+ 'function greet(): string[] {};greet()',
+ 'function greet(): Array<string> {};greet();',
+ 'function greet(): Array<Array<string>> {};greet();',
+ 'function greet(param: Array<string>): string { return param; };greet();',
+ 'function greet(param: Array<string>): Array<string> { return param; };greet();',
+ ];
+
+ const invalidTestCases = [
+ "const age: any = 'seventeen';age;",
+ "const ages: any[] = ['seventeen'];ages;",
+ "const ages: Array<any> = ['seventeen'];ages;",
+ 'function greet(): any {};greet();',
+ 'function greet(): any[] {};greet();',
+ 'function greet(): Array<any> {};greet();',
+ 'function greet(): Array<Array<any>> {};greet();',
+ 'function greet(param: Array<any>): string { return param; };greet();',
+ 'function greet(param: Array<any>): Array<any> { return param; };greet();',
+ ];
+
+ for (const invalidTestCase of invalidTestCases) {
+ const {diagnostics} = await testLint(invalidTestCase, false, 'module', [
+ 'ts',
+ 'flow',
+ ]);
+ t.snapshot(diagnostics);
+ }
+
+ for (const validTestCase of validTestCases) {
+ const {diagnostics} = await testLint(validTestCase, false, 'module', [
+ 'ts',
+ 'flow',
+ ]);
+ t.is(diagnostics.length, 0);
+ }
+});

add tests

also modified testLint to accept ts/flow syntax