fix(es/lints: Handle ts export import equals (#5225)

This commit is contained in:
magic-akari 2022-07-17 13:04:37 +08:00 committed by GitHub
parent 1c2d5868ef
commit 04de455a9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,11 @@
{
"$schema": "http://json.schemastore.org/swcrc",
"jsc": {
"parser": {
"syntax": "typescript"
}
},
"module": {
"type": "commonjs"
}
}

View File

@ -0,0 +1,5 @@
export import _ = require("lodash");
const lodash = _;
export { lodash as _ };

View File

@ -0,0 +1,16 @@
x the name `_` is exported multiple times
,-[1:1]
1 | export import _ = require("lodash");
: |
: `-- previous exported here
2 |
3 | const lodash = _;
4 |
5 | export { lodash as _ };
: |
: `-- exported more than once
`----
Error:
> Exported identifiers must be unique

View File

@ -136,6 +136,12 @@ impl Visit for DuplicateExports {
};
}
fn visit_ts_import_equals_decl(&mut self, n: &TsImportEqualsDecl) {
if n.is_export && !n.is_type_only && !n.declare {
self.add(&n.id)
}
}
fn visit_ts_export_assignment(&mut self, n: &TsExportAssignment) {
self.add_export_assign(n.span);
}