Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New typescript flow rule #2614

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1830d7a
add debug command for new rule
azyzz228 Dec 5, 2022
5684be8
draft files for the rule, test, docs.
azyzz228 Dec 5, 2022
7d1ebbd
add 2 test cases for each option
azyzz228 Dec 5, 2022
6141499
add typescript-flow alpha version
azyzz228 Dec 5, 2022
daaf8aa
add test cases for single option none
azyzz228 Dec 7, 2022
50ce08e
add blank docs for new rule
azyzz228 Dec 7, 2022
3321565
change export map to include word 'type' as a key for namespace when …
azyzz228 Dec 7, 2022
8bf8556
add new schema, comments, and handle single config option when it is …
azyzz228 Dec 7, 2022
bb172d6
delete none option and its code
azyzz228 Dec 8, 2022
803dde0
refactor and finish fixer for strict separate optiop
azyzz228 Dec 11, 2022
74ba6d3
add namespace test cases to invalid strict separate
azyzz228 Dec 11, 2022
06705cc
add default type export
azyzz228 Dec 11, 2022
bf6063a
add valid cases for strict separate
azyzz228 Dec 11, 2022
4a6a9bc
finish strict separate option
azyzz228 Dec 11, 2022
08d9832
add strict inline with only import
azyzz228 Dec 11, 2022
4b5e577
add test cases for strict inline with only one import
azyzz228 Dec 11, 2022
8f7239d
add invalid default import test cases for inline option
azyzz228 Dec 13, 2022
7e5388c
add fixer for inline option with ImportDefault specifier
azyzz228 Dec 13, 2022
8c7ff3f
fix one failing test case in default rule
azyzz228 Dec 14, 2022
250a022
add more named import test cases for strict and inline options
azyzz228 Dec 14, 2022
a630161
remove unnecessary comments
azyzz228 Dec 14, 2022
366ac51
added comment check if inline import is supported
azyzz228 Dec 14, 2022
5f79ac6
add check for TS version support for inline type import
azyzz228 Dec 14, 2022
150af6f
add invalid test case with repeated import with namespace to inline o…
azyzz228 Dec 14, 2022
64757e8
add support for namespace in repeated source for inline option
azyzz228 Dec 14, 2022
e05f4c2
add new typescript flow to src/index
azyzz228 Dec 15, 2022
fe60ea1
fix default type import with inline option
azyzz228 Dec 31, 2022
944d967
add TSX file and export/import type cases for typescript flow
azyzz228 Dec 31, 2022
a8d9ba1
add error messages
azyzz228 Jan 8, 2023
051efd2
delete unnecessary comments
azyzz228 Jan 8, 2023
b42c4d5
add 2 default import type test cases
azyzz228 Jan 8, 2023
b4cc95a
add docs
azyzz228 Jan 8, 2023
97d2074
remove custom script
azyzz228 Jan 8, 2023
fc0c163
restore ExportMap to the version from main branch
azyzz228 Jan 8, 2023
c088081
refactor specifier cache loop to function for config = separate
azyzz228 Feb 1, 2023
accfa3a
refactor by adding function for every piece of logic
azyzz228 Feb 2, 2023
a6246b2
remove redundant comments
azyzz228 Feb 14, 2023
05c62b8
Merge branch 'import-js:main' into new-typescript-flow-rule
azyzz228 Sep 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add more named import test cases for strict and inline options
azyzz228 committed Dec 14, 2022
commit 250a0227e0346ee383984008795b126148ff3a93
56 changes: 54 additions & 2 deletions tests/src/rules/typescript-flow.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ context('TypeScript', function () {
settings,
options: ['separate'],
}),
// default imports are ignored for strict option separate
// default imports are ignored for strict option separate. Question. TODO
test({
code: `import Bar from "./typescript.ts"`,
parser,
@@ -67,12 +67,24 @@ context('TypeScript', function () {
settings,
options: ['inline'],
}),
test({
code: `import { type MyType as Persona } from "./typescript.ts"`,
parser,
settings,
options: ['inline'],
}),
test({
code: `import { type MyType, Bar, MyEnum } from "./typescript.ts"`,
parser,
settings,
options: ['inline'],
}),
test({
code: `import { type MyType as Persona, Bar as Bar, MyEnum } from "./typescript.ts"`,
parser,
settings,
options: ['inline'],
}),
],
invalid: [
test({
@@ -85,6 +97,16 @@ context('TypeScript', function () {
}],
output: 'import {Bar} from "./typescript.ts"\nimport type { MyType } from "./typescript.ts"',
}),
test({
code: 'import {type MyType as Persona,Bar} from "./typescript.ts"',
parser,
settings,
options: ['separate'],
errors: [{
message: 'BOOM',
}],
output: 'import {Bar} from "./typescript.ts"\nimport type { MyType as Persona } from "./typescript.ts"',
}),
test({
code: 'import {type MyType,Bar,type Foo} from "./typescript.ts"',
parser,
@@ -95,6 +117,16 @@ context('TypeScript', function () {
}],
output: 'import {Bar} from "./typescript.ts"\nimport type { MyType, Foo } from "./typescript.ts"',
}),
test({
code: 'import {type MyType as Persona,Bar,type Foo as Baz} from "./typescript.ts"',
parser,
settings,
options: ['separate'],
errors: [{
message: 'BOOM',
}],
output: 'import {Bar} from "./typescript.ts"\nimport type { MyType as Persona, Foo as Baz } from "./typescript.ts"',
}),
test({
code: 'import {type MyType,Bar as Namespace} from "./typescript.ts"',
parser,
@@ -125,7 +157,7 @@ context('TypeScript', function () {
}],
output: 'import type { MyType as Bar, Foo} from "./typescript.ts"',
}),
// the space is left over when 'type' is removed. Question
// the space is left over when 'type' is removed. Question. TODO
test({
code: 'import type {MyType} from "./typescript.ts"',
parser,
@@ -156,6 +188,16 @@ context('TypeScript', function () {
}],
output: 'import {MyEnum, type MyType, type Bar} from "./typescript.ts"',
}),
test({
code: 'import type {MyType as Persona, Bar as Foo} from "./typescript.ts";import {MyEnum} from "./typescript.ts"',
parser,
settings,
options: ['inline'],
errors: [{
message: 'BOOM',
}],
output: 'import {MyEnum, type MyType as Persona, type Bar as Foo} from "./typescript.ts"',
}),
test({
code: 'import type {MyType, Bar} from "./typescript.ts";import {default as B} from "./typescript.ts"',
parser,
@@ -176,6 +218,16 @@ context('TypeScript', function () {
}],
output: 'import defaultExport, { type MyType, type Bar } from "./typescript.ts"',
}),
test({
code: 'import type {MyType as Persona, Bar as Foo} from "./typescript.ts";import defaultExport from "./typescript.ts"',
parser,
settings,
options: ['inline'],
errors: [{
message: 'BOOM',
}],
output: 'import defaultExport, { type MyType as Persona, type Bar as Foo } from "./typescript.ts"',
}),
// // TODO: what to do here? Output: import * as b, { type MyType, type Bar } from "./typescript.ts" ?
// test({
// code: 'import type {MyType, Bar} from "./typescript.ts";import * as b from "./typescript.ts"',