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

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feat/decorator-clas…
Browse files Browse the repository at this point in the history
…s-member

# Conflicts:
#	crates/rome_js_formatter/src/js/auxiliary/decorator.rs
#	crates/rome_js_formatter/tests/quick_test.rs
#	crates/rome_js_formatter/tests/specs/prettier/js/decorator-comments/comments.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators-export/after_export.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/class-expression/member-expression.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/classes.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/comments.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/methods.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/mobx.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiline.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/multiple.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/js/decorators/redux.js.snap
#	crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators-comments.ts.snap
#	crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/decorators.ts.snap
#	crates/rome_js_formatter/tests/specs/prettier/typescript/decorators/inline-decorators.ts.snap
#	crates/rome_js_formatter/tests/specs/ts/decoartors.ts.snap
#	crates/rome_js_parser/src/syntax/auxiliary.rs
#	crates/rome_js_parser/src/syntax/class.rs
#	crates/rome_js_parser/src/syntax/expr.rs
#	crates/rome_js_parser/src/syntax/js_parse_error.rs
#	crates/rome_js_parser/src/syntax/module.rs
#	crates/rome_js_parser/src/syntax/stmt.rs
#	crates/rome_js_parser/src/tests.rs
#	crates/rome_js_parser/test_data/inline/err/decorator.rast
#	crates/rome_js_parser/test_data/inline/err/decorator_class_declaration.rast
#	crates/rome_js_parser/test_data/inline/err/decorator_class_declaration_top_level.rast
#	crates/rome_js_parser/test_data/inline/err/decorator_export_class_clause.rast
#	crates/rome_js_parser/test_data/inline/err/decorator_expression_class.js
#	crates/rome_js_parser/test_data/inline/err/decorator_expression_class.rast
#	crates/rome_js_parser/test_data/inline/err/ts_declare_const_initializer.rast
#	crates/rome_js_parser/test_data/inline/err/ts_export_declare.rast
#	crates/rome_js_parser/test_data/inline/err/ts_invalid_decorated_class_members.rast
#	crates/rome_js_parser/test_data/inline/ok/decorator.rast
#	crates/rome_js_parser/test_data/inline/ok/decorator.ts
#	crates/rome_js_parser/test_data/inline/ok/decorator_export_class_clause.rast
#	crates/rome_js_parser/test_data/inline/ok/export_class_clause.rast
#	crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.rast
#	crates/rome_js_parser/test_data/inline/ok/ts_class_decorator.ts
#	crates/rome_js_parser/test_data/inline/ok/ts_decorated_class_members.rast
#	crates/rome_js_parser/test_data/inline/ok/ts_decorator_call_expression_with_arrow.rast
#	crates/rome_js_parser/test_data/inline/ok/ts_parameter_option_binding_pattern.rast
#	crates/rome_js_syntax/src/generated/nodes.rs
  • Loading branch information
denbezrukov committed Apr 27, 2023
2 parents 18df5e4 + 19b60d4 commit fd86dac
Show file tree
Hide file tree
Showing 612 changed files with 17,999 additions and 4,122 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ indent_size = 2

# YAML doesn't support hard tabs 🙃
# Templates that will be weird with hard tabs in the website editor
[{**.yml, **.md, **.rs, **.mdx}]
[{**.yml, **.md, **.rs, **.mdx, justfile}]
indent_style = space

[*.rs]
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ jobs:
os: [windows-latest, ubuntu-latest]

steps:
# ref: https://github.com/orgs/community/discussions/26952
- name: Support longpaths
if: matrix.os == 'windows-latest'
run: git config --system core.longpaths true
- name: Checkout repository
uses: actions/checkout@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Profile-*.json
# Ignore third-party files
**/node_modules
**/dist
**/build
npm/cli-*
.pnpm-debug.log

Expand Down
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@

### CLI

### Linter

#### New rules

- [`noUselessConstructor`](https://docs.rome.tools/lint/rules/noUselessConstructor/)
- [`useLiteralEnumMembers`](https://docs.rome.tools/lint/rules/useLiteralEnumMembers/)

#### Other changes
- Add new command `rome migrate` the transform the configuration file `rome.json`
when there are breaking changes.

### Configuration
### Editors

- Fix an issue where the VSCode extension duplicates text when using VSCode git utilities [#4338]
- Remove code assists from being added to the code actions when apply fixes;
-
### Formatter

- Fix an issue where formatting of JSX string literals property values were using incorrect quotes [#4054](https://github.com/rome/tools/issues/4054)
Expand All @@ -28,8 +39,9 @@ when there are breaking changes.
the code action is not formatted.
- Fixed an issue that [`useShorthandArrayType`](https://docs.rome.tools/lint/rules/useShorthandArrayType) rule did not handle nested ReadonlyArray types correctly and erroneously reported TsObjectType [#4354](https://github.com/rome/tools/issues/4353).
- [`noUndeclaredVariables`](https://docs.rome.tools/lint/rules/noUndeclaredVariables) detects globals based on the file type.

- Fix an issue when `noUndeclaredVariables` incorrectly identifies `AggregateError` as an undeclared variable. [#4365](https://github.com/rome/tools/issues/4365)
- Fix an issue that `useLiteralKeys` rule doesn't ignore valid uses of square bracket notation. [#4370](https://github.com/rome/tools/issues/4370)

#### New rules
- [`noConfusingArrow`](https://docs.rome.tools/lint/rules/noConfusingArrow/)
- [`noRedundantRoles`](https://docs.rome.tools/lint/rules/noRedundantRoles/)
Expand All @@ -38,6 +50,7 @@ the code action is not formatted.
- [`noConsoleLog`](https://docs.rome.tools/lint/rules/noConsoleLog/)
- [`noForEach`](https://docs.rome.tools/lint/rules/noForEach/)
- [`useLiteralKeys`](https://docs.rome.tools/lint/rules/useLiteralKeys/)
- [`noConstantCondition`](https://docs.rome.tools/lint/rules/noConstantCondition/)

### Parser

Expand All @@ -47,7 +60,7 @@ the code action is not formatted.
- import "module" assert {}
+ import "module" with {}
```

- Allow decorators before `export` and `export default`. [#4252](https://github.com/rome/tools/issues/4252)

### VSCode
### JavaScript APIs
Expand Down
5 changes: 5 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/rome_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rome_json_formatter = { path = "../rome_json_formatter" }
rome_json_syntax = { path = "../rome_json_syntax" }
rome_migrate = { path = "../rome_migrate" }
rome_rowan = { path = "../rome_rowan" }
indexmap = { workspace = true }

[target.'cfg(unix)'.dependencies]
libc = "0.2.127"
Expand Down
13 changes: 11 additions & 2 deletions crates/rome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
use crate::configuration::load_configuration;
use crate::parse_arguments::{apply_files_settings_from_cli, apply_format_settings_from_cli};
use crate::parse_arguments::{
apply_files_settings_from_cli, apply_format_settings_from_cli, apply_vcs_settings_from_cli,
};
use crate::vcs::store_path_to_ignore_from_vcs;
use crate::{execute_mode, CliDiagnostic, CliSession, Execution, TraversalMode};
use rome_console::{markup, ConsoleExt};
use rome_diagnostics::{DiagnosticExt, PrintDiagnostic, Severity};
use rome_service::workspace::{FixFileMode, UpdateSettingsParams};

/// Handler for the "check" command of the Rome CLI
pub(crate) fn check(mut session: CliSession) -> Result<(), CliDiagnostic> {
let (mut configuration, diagnostics, _) = load_configuration(&mut session)?.consume();
let (mut configuration, diagnostics, configuration_path) =
load_configuration(&mut session)?.consume();
if !diagnostics.is_empty() {
let console = &mut session.app.console;
console.log(markup!{
Expand All @@ -22,6 +26,11 @@ pub(crate) fn check(mut session: CliSession) -> Result<(), CliDiagnostic> {
}
apply_files_settings_from_cli(&mut session, &mut configuration)?;
apply_format_settings_from_cli(&mut session, &mut configuration)?;
apply_vcs_settings_from_cli(&mut session, &mut configuration)?;

// check if support of git ignore files is enabled
let vcs_base_path = configuration_path.or(session.app.fs.working_directory());
store_path_to_ignore_from_vcs(&mut session, &mut configuration, vcs_base_path)?;

session
.app
Expand Down
14 changes: 12 additions & 2 deletions crates/rome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use crate::parse_arguments::{apply_files_settings_from_cli, apply_format_settings_from_cli};
use crate::parse_arguments::{
apply_files_settings_from_cli, apply_format_settings_from_cli, apply_vcs_settings_from_cli,
};
use crate::vcs::store_path_to_ignore_from_vcs;
use crate::{
configuration::load_configuration, execute_mode, CliDiagnostic, CliSession, Execution,
TraversalMode,
Expand All @@ -11,7 +14,8 @@ use rome_service::workspace::UpdateSettingsParams;

/// Handler for the "ci" command of the Rome CLI
pub(crate) fn ci(mut session: CliSession) -> Result<(), CliDiagnostic> {
let (mut configuration, diagnostics, _) = load_configuration(&mut session)?.consume();
let (mut configuration, diagnostics, configuration_path) =
load_configuration(&mut session)?.consume();

if !diagnostics.is_empty() {
let console = &mut session.app.console;
Expand Down Expand Up @@ -77,6 +81,12 @@ pub(crate) fn ci(mut session: CliSession) -> Result<(), CliDiagnostic> {
apply_format_settings_from_cli(&mut session, &mut configuration)?;
}

apply_vcs_settings_from_cli(&mut session, &mut configuration)?;

// check if support of git ignore files is enabled
let vcs_base_path = configuration_path.or(session.app.fs.working_directory());
store_path_to_ignore_from_vcs(&mut session, &mut configuration, vcs_base_path)?;

session
.app
.workspace
Expand Down
12 changes: 10 additions & 2 deletions crates/rome_cli/src/commands/format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::configuration::load_configuration;
use crate::execute::ReportMode;
use crate::parse_arguments::{apply_files_settings_from_cli, apply_format_settings_from_cli};
use crate::parse_arguments::{
apply_files_settings_from_cli, apply_format_settings_from_cli, apply_vcs_settings_from_cli,
};
use crate::vcs::store_path_to_ignore_from_vcs;
use crate::{execute_mode, CliDiagnostic, CliSession, Execution, TraversalMode};
use rome_console::{markup, ConsoleExt};
use rome_diagnostics::{DiagnosticExt, PrintDiagnostic, Severity};
Expand All @@ -9,7 +12,8 @@ use std::path::PathBuf;

/// Handler for the "format" command of the Rome CLI
pub(crate) fn format(mut session: CliSession) -> Result<(), CliDiagnostic> {
let (mut configuration, diagnostics, _) = load_configuration(&mut session)?.consume();
let (mut configuration, diagnostics, configuration_path) =
load_configuration(&mut session)?.consume();
if !diagnostics.is_empty() {
let console = &mut session.app.console;
console.log(markup!{
Expand All @@ -25,7 +29,11 @@ pub(crate) fn format(mut session: CliSession) -> Result<(), CliDiagnostic> {

apply_files_settings_from_cli(&mut session, &mut configuration)?;
apply_format_settings_from_cli(&mut session, &mut configuration)?;
apply_vcs_settings_from_cli(&mut session, &mut configuration)?;

// check if support of git ignore files is enabled
let vcs_base_path = configuration_path.or(session.app.fs.working_directory());
store_path_to_ignore_from_vcs(&mut session, &mut configuration, vcs_base_path)?;
session
.app
.workspace
Expand Down
30 changes: 21 additions & 9 deletions crates/rome_cli/src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const MAIN: Markup = markup! {
"<Dim>"--colors=<off|force>"</Dim>" Set the formatting mode for markup: \"off\" prints everything as plain text, \"force\" forces the formatting of markup using ANSI even if the console output is determined to be incompatible
"<Dim>"--use-server"</Dim>" Connect to a running instance of the Rome daemon server
"<Dim>"--version"</Dim>" Show the Rome version information and quit
"<Dim>"--files-max-size"</Dim>" The maximum allowed size for source code files in bytes (default: 1MB)
"
"<Dim>"--files-max-size"</Dim>" The maximum allowed size for source code files in bytes (default: 1MB)"
{VCS_OPTIONS}
};

const CHECK: Markup = markup! {
Expand All @@ -46,11 +46,12 @@ const CHECK: Markup = markup! {
"<Dim>"--config-path"</Dim>" Set the filesystem path to the directory of the rome.json configuration file
"<Dim>"--verbose"</Dim>" Print additional verbose advices on diagnostics
"
{VCS_OPTIONS}
};

const FORMAT_OPTIONS: Markup = markup! {
"
"<Dim>"--indent-style <tabs|space>"</Dim>" Change the indention character (default: tabs)
"<Dim>"--indent-style <tab|space>"</Dim>" Change the indention character (default: tab)
"<Dim>"--indent-size <number>"</Dim>" If the indentation style is set to spaces, determine how many spaces should be used for indentation (default: 2)
"<Dim>"--line-width <number>"</Dim>" Change how many characters the formatter is allowed to print in a single line (default: 80)
"<Dim>"--quote-style <single|double>"</Dim>" Changes the quotation character for strings (default: double)
Expand All @@ -60,6 +61,16 @@ const FORMAT_OPTIONS: Markup = markup! {
"
};

const VCS_OPTIONS: Markup = markup! {
"
"<Dim>"--vcs-enabled <true|false>"</Dim>" Whether Rome should integrate itself with the VCS client
"<Dim>"--vcs-client-kind <git>"</Dim>" The name of the client
"<Dim>"--vcs-use-ignore-file <true|false>"</Dim>" Whether Rome should ignore the paths inside the ignore file
"<Dim>"--vcs-root <string>"</Dim>" Where Rome should look for VCS files. If a rome.json is present, Rome will append this root to the path of where
rome.json is.
"
};

const CI: Markup = markup! {
"Rome CI: Run the linter and formatter check on a set of files
Expand All @@ -74,13 +85,14 @@ const CI: Markup = markup! {
rome ci ./src ./internal ./scripts
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--formatter-enabled"</Dim>" Allow to enable or disable the formatter check. (default: true)
"<Dim>"--linter-enabled"</Dim>" Allow to enable or disable the linter check. (default: true)
"<Dim>"--organize-imports-enabled"</Dim>" Allow to enable or disable the organize imports. (default: true)
"<Dim>"--formatter-enabled <true|false>"</Dim>" Allow to enable or disable the formatter check. (default: true)
"<Dim>"--linter-enabled <true|false>"</Dim>" Allow to enable or disable the linter check. (default: true)
"<Dim>"--organize-imports-enabled <true|false>"</Dim>" Allow to enable or disable the organize imports. (default: true)
"<Dim>"--max-diagnostics"</Dim>" Cap the amount of diagnostics displayed (default: 50)
"<Dim>"--config-path"</Dim>" Set the filesystem path to the directory of the rome.json configuration file
"<Dim>"--verbose"</Dim>" Print additional verbose advices on diagnostics"
{FORMAT_OPTIONS}
{VCS_OPTIONS}
};

const FORMAT: Markup = markup! {
Expand All @@ -101,10 +113,10 @@ const FORMAT: Markup = markup! {
"<Dim>"--skip-errors"</Dim>" Skip over files containing syntax errors instead of emitting an error diagnostic.
"<Dim>"--max-diagnostics"</Dim>" Cap the amount of diagnostics displayed (default: 50)
"<Dim>"--config-path"</Dim>" Set the filesystem path to the directory of the rome.json configuration file
"<Dim>"--verbose"</Dim>" Print additional verbose advices on diagnostics"
"<Dim>"--verbose"</Dim>" Print additional verbose advices on diagnostics
"<Dim>"--stdin-file-path <string>"</Dim>" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js"
{FORMAT_OPTIONS}
""<Dim>"--stdin-file-path <string>"</Dim>" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
"
{VCS_OPTIONS}
};

const INIT: Markup = markup! {
Expand Down
3 changes: 2 additions & 1 deletion crates/rome_cli/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ use crate::{CliDiagnostic, CliSession};
/// Handler for the "check" command of the Rome CLI
pub(crate) fn migrate(mut session: CliSession) -> Result<(), CliDiagnostic> {
let (_, _, path) = load_configuration(&mut session)?.consume();
let config_name = session.app.fs.config_name();
if let Some(path) = path {
execute_mode(
Execution::new(TraversalMode::Migrate {
write: session.args.contains("--dry-run"),
configuration_path: path,
configuration_path: path.join(config_name),
}),
session,
)
Expand Down
1 change: 1 addition & 0 deletions crates/rome_cli/src/commands/rage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ impl Display for RageConfiguration<'_, '_> {
{KeyValuePair("Formatter disabled", markup!({DebugDisplay(configuration.is_formatter_disabled())}))}
{KeyValuePair("Linter disabled", markup!({DebugDisplay(configuration.is_linter_disabled())}))}
{KeyValuePair("Organize imports disabled", markup!({DebugDisplay(configuration.is_organize_imports_disabled())}))}
{KeyValuePair("VCS disabled", markup!({DebugDisplay(configuration.is_vcs_disabled())}))}
).fmt(fmt)?
}
Err(err) => markup! (
Expand Down
Loading

0 comments on commit fd86dac

Please sign in to comment.