Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Merge branch 'main' into group-organized-imports-by-distance
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr committed Jul 31, 2023
2 parents 5abafe3 + 675b8ed commit 90da7f5
Show file tree
Hide file tree
Showing 539 changed files with 16,798 additions and 3,738 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ jobs:
uses: moonrepo/setup-rust@v0
with:
components: rustfmt
- name: Run rustfmt
run: cargo fmt --all --check
bins: taplo-cli
- name: Run format
run: |
cargo fmt --all --check
taplo fmt -- --locked
lint:
name: Lint Rust Files
Expand Down Expand Up @@ -115,7 +118,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18
- name: Cache pnpm modules
uses: actions/cache@v3
with:
Expand All @@ -125,7 +128,7 @@ jobs:
${{ runner.os }}-
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
version: 8
- name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
${{ runner.os }}-
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
version: 8
- name: Install toolchain
uses: moonrepo/setup-rust@v0
- name: Build WASM module for the web
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18

- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}
Expand Down Expand Up @@ -187,7 +187,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Set release infos
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_js_api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18

- name: Install wasm-pack
uses: jetli/wasm-pack-action@v0.4.0
Expand All @@ -81,7 +81,7 @@ jobs:
${{ runner.os }}-
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
version: 8

- name: Set release infos
if: needs.check.outputs.prerelease == 'true'
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Set release infos
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_lsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18

- name: Update package.json version
if: needs.check.outputs.prerelease == 'true'
Expand Down Expand Up @@ -195,7 +195,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18
registry-url: 'https://registry.npmjs.org'

- name: Publish extension to Microsoft Marketplace (pre-release)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
${{ runner.os }}-
- uses: pnpm/action-setup@v2.2.4
with:
version: 7
version: 8
- name: Install toolchain
uses: moonrepo/setup-rust@v0
- name: Install libraries
Expand All @@ -55,4 +55,4 @@ jobs:
pnpm --prefix npm/backend-jsonrpc run build
- name: CI checks
working-directory: npm/js-api
run: pnpm ci
run: pnpm run ci
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@

- Fixed the diagnostics emitted when running the `rome format` command;

- Rome doesn't warn anymore when discovering (possibly infinite) symbolic links between directories.
This fixes [#4193](https://github.com/rome/tools/issues/4193) which resulted in incorrect warnings
when a single file or directory was pointed at by multiple symbolic links. Symbolic links to other
symbolic links do still trigger warnings if they are too deeply nested.

### Configuration

#### Other changes
Expand Down Expand Up @@ -142,6 +147,10 @@ if no error diagnostics are emitted.

This rule recommends using `Number.isNaN` instead of the global and unsafe `isNaN` that attempts a type coercion.

- Add [`noUnsafeDeclarationMerging`](https://docs.rome.tools/lint/rules/noUnsafeDeclarationMerging/)

This rule disallows declaration merging between an interface and a class.

- Add [`useArrowFunction`](https://docs.rome.tools/lint/rules/usearrowfunction/)

This rule proposes turning function expressions into arrow functions.
Expand Down Expand Up @@ -192,6 +201,20 @@ if no error diagnostics are emitted.

- Fix [`noDuplicateCase`](https://docs.rome.tools/lint/rules/noDuplicateCase/) rule that erroneously reported as equals the strings literals `"'"` and `'"'` [#4706](https://github.com/rome/tools/issues/4706).

- Improve [`useEnumInitializers`](https://docs.rome.tools/lint/rules/useEnumInitializers/)

The rule now reports all uninitialized members of an enum in a single diagnostic.

Moreover, ambient enum declarations are now ignored.
This avoids reporting ambient enum declarations in _TypeScript_ declaration files.

```ts
declare enum Weather {
Rainy,
Sunny,
}
```

- Relax [`noBannedTypes`](https://docs.rome.tools/lint/rules/nobannedtypes/) and improve documentation

The rule no longer reports a user type that reuses a banned type name.
Expand Down
6 changes: 5 additions & 1 deletion crates/rome_cli/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use rome_deserialize::json::deserialize_from_json_str;
use rome_deserialize::Deserialized;
use rome_diagnostics::{DiagnosticExt, Error, PrintDiagnostic};
use rome_fs::{FileSystem, OpenOptions};
use rome_json_parser::JsonParserOptions;
use rome_service::configuration::diagnostics::CantLoadExtendFile;
use rome_service::configuration::ConfigurationPayload;
use rome_service::{
Expand Down Expand Up @@ -72,7 +73,10 @@ impl LoadedConfiguration {
)

})?;
let deserialized = deserialize_from_json_str::<Configuration>(content.as_str());
let deserialized = deserialize_from_json_str::<Configuration>(
content.as_str(),
JsonParserOptions::default(),
);
deserialized_configurations.push(deserialized)
}
Ok(deserialized_configurations)
Expand Down
127 changes: 86 additions & 41 deletions crates/rome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,15 +797,11 @@ fn fs_error_dereferenced_symlink() {
let fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let root_path = temp_dir().join("rome_test_broken_symlink");
let root_path = temp_dir().join("check_rome_test_broken_symlink");
let subdir_path = root_path.join("prefix");

#[allow(unused_must_use)]
{
remove_dir_all(root_path.display().to_string().as_str());
}
create_dir(root_path.display().to_string().as_str()).unwrap();
create_dir(subdir_path).unwrap();
let _ = remove_dir_all(&root_path);
create_dir_all(subdir_path).unwrap();

#[cfg(target_family = "unix")]
{
Expand Down Expand Up @@ -840,39 +836,28 @@ fn fs_error_dereferenced_symlink() {
}

#[test]
fn fs_error_infinite_symlink_exapansion() {
fn fs_error_infinite_symlink_expansion_to_dirs() {
let fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let root_path = temp_dir().join("rome_test_infinite_symlink_exapansion");
let root_path = temp_dir().join("check_rome_test_infinite_symlink_expansion_to_dirs");
let subdir1_path = root_path.join("prefix");
let subdir2_path = root_path.join("foo").join("bar");

#[allow(unused_must_use)]
{
remove_dir_all(root_path.display().to_string().as_str());
}
create_dir(root_path.display().to_string().as_str()).unwrap();
create_dir(subdir1_path.clone()).unwrap();

create_dir_all(subdir2_path.clone()).unwrap();
let _ = remove_dir_all(&root_path);
create_dir_all(&subdir1_path).unwrap();
create_dir_all(&subdir2_path).unwrap();

#[cfg(target_family = "unix")]
{
symlink(subdir1_path.clone(), root_path.join("self_symlink1")).unwrap();
symlink(subdir1_path, subdir2_path.join("self_symlink2")).unwrap();
symlink(&subdir2_path, subdir1_path.join("symlink1")).unwrap();
symlink(subdir1_path, subdir2_path.join("symlink2")).unwrap();
}

#[cfg(target_os = "windows")]
{
check_windows_symlink!(symlink_dir(
subdir1_path.clone(),
root_path.join("self_symlink1")
));
check_windows_symlink!(symlink_dir(
subdir1_path,
subdir2_path.join("self_symlink2")
));
check_windows_symlink!(symlink_dir(&subdir2_path, &subdir1_path.join("symlink1")));
check_windows_symlink!(symlink_dir(subdir1_path, subdir2_path.join("symlink2")));
}

let result = run_cli(
Expand All @@ -887,13 +872,69 @@ fn fs_error_infinite_symlink_exapansion() {

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"fs_error_infinite_symlink_expansion",
"fs_error_infinite_symlink_expansion_to_dirs",
fs,
console,
result,
));
}

#[test]
fn fs_error_infinite_symlink_expansion_to_files() {
let mut console = BufferConsole::default();

let root_path = temp_dir().join("check_rome_test_infinite_symlink_expansion_to_files");
let subdir1_path = root_path.join("prefix");
let subdir2_path = root_path.join("foo").join("bar");

let _ = remove_dir_all(&root_path);
create_dir_all(&subdir1_path).unwrap();
create_dir_all(&subdir2_path).unwrap();

let symlink1_path = subdir1_path.join("symlink1");
let symlink2_path = subdir2_path.join("symlink2");

#[cfg(target_family = "unix")]
{
symlink(&symlink2_path, &symlink1_path).unwrap();
symlink(&symlink1_path, &symlink2_path).unwrap();
}

#[cfg(target_os = "windows")]
{
check_windows_symlink!(symlink_dir(&symlink2_path, &symlink1_path));
check_windows_symlink!(symlink_dir(&symlink1_path, &symlink2_path));
}

let result = run_cli(
DynRef::Owned(Box::new(OsFileSystem)),
&mut console,
Args::from([("check"), (root_path.display().to_string().as_str())].as_slice()),
);

remove_dir_all(root_path).unwrap();

assert!(result.is_err(), "run_cli returned {result:?}");

// Don't use a snapshot here, since the diagnostics can be reported in
// arbitrary order:
assert!(console
.out_buffer
.iter()
.flat_map(|msg| msg.content.0.iter())
.any(|node| node.content.contains("Deeply nested symlink expansion")));
assert!(console
.out_buffer
.iter()
.flat_map(|msg| msg.content.0.iter())
.any(|node| node.content.contains(&symlink1_path.display().to_string())));
assert!(console
.out_buffer
.iter()
.flat_map(|msg| msg.content.0.iter())
.any(|node| node.content.contains(&symlink2_path.display().to_string())));
}

#[test]
fn fs_error_read_only() {
let mut fs = MemoryFileSystem::new_read_only();
Expand Down Expand Up @@ -970,28 +1011,27 @@ fn fs_error_unknown() {
// │ └── test.js // ok
// └── src
// ├── symlink_testcase1_1 -> hidden_nested
// ├── symlink_testcase1_3 -> hidden_testcase1/test/test.js
// └── symlink_testcase2 -> hidden_testcase2
#[test]
fn fs_files_ignore_symlink() {
let fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let root_path = temp_dir().join("rome_test_files_ignore_symlink");
let root_path = temp_dir().join("check_rome_test_files_ignore_symlink");
let src_path = root_path.join("src");

let testcase1_path = root_path.join("hidden_testcase1");
let testcase1_sub_path = testcase1_path.join("test");
let testcase1_sub_file_path = testcase1_sub_path.join("test.js");
let testcase2_path = root_path.join("hidden_testcase2");

let nested_path = root_path.join("hidden_nested");
let nested_sub_path = nested_path.join("test");

#[allow(unused_must_use)]
{
remove_dir_all(root_path.display().to_string().as_str());
}
create_dir(root_path.display().to_string().as_str()).unwrap();
create_dir(src_path.clone()).unwrap();
let _ = remove_dir_all(&root_path);
create_dir(&root_path).unwrap();
create_dir(&src_path).unwrap();
create_dir_all(testcase1_sub_path.clone()).unwrap();
create_dir(testcase2_path.clone()).unwrap();
create_dir_all(nested_sub_path.clone()).unwrap();
Expand All @@ -1000,27 +1040,32 @@ fn fs_files_ignore_symlink() {
let symlink_testcase1_1_path = src_path.join("symlink_testcase1_1");
// hidden_nested/test/symlink_testcase1_2
let symlink_testcase1_2_path = nested_sub_path.join("symlink_testcase1_2");
// src/symlink_testcase1_3
let symlink_testcase1_3_path = src_path.join("symlink_testcase1_3");
// src/symlink_testcase2
let symlink_testcase2_path = src_path.join("symlink_testcase2");

#[cfg(target_family = "unix")]
{
// src/test/symlink_testcase1_1 -> hidden_nested
// src/symlink_testcase1_1 -> hidden_nested
symlink(nested_path, symlink_testcase1_1_path).unwrap();
// hidden_nested/test/symlink_testcase1_2 -> hidden_testcase1
symlink(testcase1_path, symlink_testcase1_2_path).unwrap();
// src/symlink_testcase1_3 -> hidden_testcase1/test/test.js
symlink(testcase1_sub_file_path, symlink_testcase1_3_path).unwrap();
// src/symlink_testcase2 -> hidden_testcase2
symlink(testcase2_path.clone(), symlink_testcase2_path).unwrap();
symlink(&testcase2_path, symlink_testcase2_path).unwrap();
}

#[cfg(target_os = "windows")]
{
check_windows_symlink!(symlink_dir(nested_path.clone(), symlink_testcase1_1_path));
check_windows_symlink!(symlink_dir(nested_path, symlink_testcase1_1_path));
check_windows_symlink!(symlink_dir(testcase1_path, symlink_testcase1_2_path));
check_windows_symlink!(symlink_dir(
testcase1_path.clone(),
symlink_testcase1_2_path
testcase1_sub_file_path,
symlink_testcase1_3_path
));
check_windows_symlink!(symlink_dir(testcase2_path.clone(), symlink_testcase2_path));
check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path));
}

let config_path = root_path.join("rome.json");
Expand Down
Loading

0 comments on commit 90da7f5

Please sign in to comment.