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

fix(no-dupe-keys): deal with BigInt keys #541

Merged
merged 6 commits into from Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
persist-credentials: false

- name: Install rust
uses: hecrj/setup-rust-action@v1.3.3
uses: hecrj/setup-rust-action@v1.3.4
with:
rust-version: "1.47.0"

Expand Down Expand Up @@ -87,8 +87,8 @@ jobs:

- name: Environment
run: |
echo ::set-env name=GH_ACTIONS::1
echo ::set-env name=RUST_BACKTRACE::full
echo "GH_ACTIONS=1" >> ${GITHUB_ENV}
echo "RUST_BACKTRACE=full" >> ${GITHUB_ENV}

- name: Format
if: contains(matrix.os, 'ubuntu')
Expand Down
29 changes: 15 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -21,7 +21,7 @@ serde = { version = "1.0.117", features = ["derive"] }
serde_json = "1.0.59"
swc_atoms = "0.2.5"
swc_common = "=0.10.5"
swc_ecmascript = { version = "=0.13.3", features = ["parser", "transforms", "utils", "visit"] }
swc_ecmascript = { version = "=0.14.0", features = ["parser", "transforms", "utils", "visit"] }
regex = "1.4.1"
once_cell = "1.5.2"
derive_more = { version = "0.99.11", features = ["display"] }
Expand Down
1 change: 1 addition & 0 deletions src/rules/no_dupe_class_members.rs
Expand Up @@ -163,6 +163,7 @@ fn normalize_prop_name(name: &PropName) -> Option<String> {
PropName::Ident(Ident { ref sym, .. }) => sym.to_string(),
PropName::Str(Str { ref value, .. }) => value.to_string(),
PropName::Num(Number { ref value, .. }) => value.to_string(),
PropName::BigInt(BigInt { ref value, .. }) => value.to_string(),
PropName::Computed(ComputedPropName { ref expr, .. }) => match &**expr {
Expr::Lit(Lit::Str(Str { ref value, .. })) => value.to_string(),
Expr::Lit(Lit::Bool(Bool { ref value, .. })) => value.to_string(),
Expand Down
19 changes: 7 additions & 12 deletions src/rules/no_dupe_keys.rs
Expand Up @@ -354,18 +354,13 @@ let x = {
hint: NoDupeKeysHint::RemoveOrRename,
}
],

// TODO(magurotuna): this leads to panic due to swc error
// It seems like tsc v4.0.2 cannot handle this either
// playground: https://www.typescriptlang.org/play?target=99&ts=4.0.2#code/MYewdgzgLgBCBGArGBeGBvAUDGBGMAXDACwBMANJgL4DcQA
// r#"var x = { 1n: 1, 1: 2 };"#: [
// {
// col: 8,
// message: variant!(NoDupeKeysMessage, Duplicate, "1"),
// hint: NoDupeKeysHint::RemoveOrRename,
// }
// ],

r#"var x = { 1n: 1, 1: 2 };"#: [
{
col: 8,
message: variant!(NoDupeKeysMessage, Duplicate, "1"),
hint: NoDupeKeysHint::RemoveOrRename,
}
],
r#"var x = { 1_0: 1, 10: 2 };"#: [
{
col: 8,
Expand Down
1 change: 1 addition & 0 deletions src/swc_util.rs
Expand Up @@ -114,6 +114,7 @@ impl StringRepr for PropName {
PropName::Ident(identifier) => Some(identifier.sym.to_string()),
PropName::Str(str) => Some(str.value.to_string()),
PropName::Num(num) => Some(num.to_string()),
PropName::BigInt(bigint) => Some(bigint.value.to_string()),
PropName::Computed(ComputedPropName { ref expr, .. }) => match &**expr {
Expr::Lit(lit) => lit.string_repr(),
Expr::Tpl(tpl) => tpl.string_repr(),
Expand Down