Skip to content

Commit

Permalink
Merge branch 'main' into 10-25-refactor_transformer_react-refresh_usi…
Browse files Browse the repository at this point in the history
…ng_semanticinjector_to_insert_statements
  • Loading branch information
Dunqing authored Oct 27, 2024
2 parents c3900d7 + 1e2f012 commit 99b251d
Show file tree
Hide file tree
Showing 97 changed files with 2,142 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .github/.generated_ast_watch_list.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ src:
- 'crates/oxc_ast/src/generated/ast_builder.rs'
- 'crates/oxc_ast/src/generated/visit.rs'
- 'crates/oxc_ast/src/generated/visit_mut.rs'
- 'npm/oxc-types/src/generated/types.d.ts'
- 'npm/oxc-types/types.d.ts'
- 'tasks/ast_tools/src/**'
- '.github/.generated_ast_watch_list.yml'
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,9 @@ jobs:
- uses: ./.github/actions/pnpm
- run: just build-wasm debug
- working-directory: wasm/parser
run: |
pnpm install --no-frozen-lockfile
pnpm build
run: pnpm run build
- name: Check output types
run: npx -y -p typescript tsc --lib es2020,dom npm/oxc-wasm/oxc_wasm.d.ts
run: npx -y -p typescript tsc --lib es2020,dom npm/parser-wasm/node/oxc_parser_wasm.d.ts

typos:
name: Spell Check
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/release_wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,4 @@ jobs:
working-directory: npm/parser-wasm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
pnpm install --no-frozen-lockfile # resolve `workspace:` in npm/parser-wams/package.json
pnpm publish --provenance --access public --no-git-checks
run: pnpm publish --provenance --access public --no-git-checks
4 changes: 2 additions & 2 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions apps/oxlint/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0.

## [0.10.3] - 2024-10-26

### Features

- 0acca58 linter: Support `--print-config all` to print config file for project (#6579) (mysteryven)

## [0.10.2] - 2024-10-22

### Refactor
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oxlint"
version = "0.10.2"
version = "0.10.3"
authors.workspace = true
categories.workspace = true
edition.workspace = true
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions crates/oxc_ast/src/ast/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ pub struct Comment {
/// The span of the comment text (without leading/trailing delimiters).
pub span: Span,

/// Line or block comment
pub kind: CommentKind,

/// Leading or trailing comment
pub position: CommentPosition,

/// Start of token this leading comment is attached to.
/// `/* Leading */ token`
/// ^ This start
/// NOTE: Trailing comment attachment is not computed yet.
pub attached_to: u32,

/// Line or block comment
pub kind: CommentKind,

/// Leading or trailing comment
pub position: CommentPosition,

/// Whether this comment has a preceding newline.
/// Used to avoid becoming a trailing comment in codegen.
pub preceded_by_newline: bool,
Expand All @@ -73,9 +73,9 @@ impl Comment {
let span = Span::new(start, end);
Self {
span,
attached_to: 0,
kind,
position: CommentPosition::Trailing,
attached_to: 0,
preceded_by_newline: false,
followed_by_newline: false,
}
Expand Down
8 changes: 8 additions & 0 deletions crates/oxc_ast/src/ast_impl/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,14 @@ impl<'a> ArrayExpressionElement<'a> {
}
}

impl<'a> ObjectPropertyKind<'a> {
/// Returns `true` if this object property is a [spread](SpreadElement).
#[inline]
pub fn is_spread(&self) -> bool {
matches!(self, Self::SpreadProperty(_))
}
}

impl<'a> PropertyKey<'a> {
#[allow(missing_docs)]
pub fn static_name(&self) -> Option<Cow<'a, str>> {
Expand Down
28 changes: 14 additions & 14 deletions crates/oxc_ast/src/generated/assert_layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use std::mem::{align_of, offset_of, size_of};

use crate::ast::*;

use oxc_regular_expression::ast::*;

use crate::ast::*;

#[cfg(target_pointer_width = "64")]
const _: () = {
assert!(size_of::<BooleanLiteral>() == 12usize);
Expand Down Expand Up @@ -1380,14 +1380,14 @@ const _: () = {
assert!(size_of::<CommentPosition>() == 1usize);
assert!(align_of::<CommentPosition>() == 1usize);

assert!(size_of::<Comment>() == 20usize);
assert!(size_of::<Comment>() == 16usize);
assert!(align_of::<Comment>() == 4usize);
assert!(offset_of!(Comment, span) == 0usize);
assert!(offset_of!(Comment, kind) == 8usize);
assert!(offset_of!(Comment, position) == 9usize);
assert!(offset_of!(Comment, attached_to) == 12usize);
assert!(offset_of!(Comment, preceded_by_newline) == 16usize);
assert!(offset_of!(Comment, followed_by_newline) == 17usize);
assert!(offset_of!(Comment, attached_to) == 8usize);
assert!(offset_of!(Comment, kind) == 12usize);
assert!(offset_of!(Comment, position) == 13usize);
assert!(offset_of!(Comment, preceded_by_newline) == 14usize);
assert!(offset_of!(Comment, followed_by_newline) == 15usize);

assert!(size_of::<NumberBase>() == 1usize);
assert!(align_of::<NumberBase>() == 1usize);
Expand Down Expand Up @@ -2939,14 +2939,14 @@ const _: () = {
assert!(size_of::<CommentPosition>() == 1usize);
assert!(align_of::<CommentPosition>() == 1usize);

assert!(size_of::<Comment>() == 20usize);
assert!(size_of::<Comment>() == 16usize);
assert!(align_of::<Comment>() == 4usize);
assert!(offset_of!(Comment, span) == 0usize);
assert!(offset_of!(Comment, kind) == 8usize);
assert!(offset_of!(Comment, position) == 9usize);
assert!(offset_of!(Comment, attached_to) == 12usize);
assert!(offset_of!(Comment, preceded_by_newline) == 16usize);
assert!(offset_of!(Comment, followed_by_newline) == 17usize);
assert!(offset_of!(Comment, attached_to) == 8usize);
assert!(offset_of!(Comment, kind) == 12usize);
assert!(offset_of!(Comment, position) == 13usize);
assert!(offset_of!(Comment, preceded_by_newline) == 14usize);
assert!(offset_of!(Comment, followed_by_newline) == 15usize);

assert!(size_of::<NumberBase>() == 1usize);
assert!(align_of::<NumberBase>() == 1usize);
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_clone_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4256,9 +4256,9 @@ impl<'alloc> CloneIn<'alloc> for Comment {
fn clone_in(&self, allocator: &'alloc Allocator) -> Self::Cloned {
Comment {
span: CloneIn::clone_in(&self.span, allocator),
attached_to: CloneIn::clone_in(&self.attached_to, allocator),
kind: CloneIn::clone_in(&self.kind, allocator),
position: CloneIn::clone_in(&self.position, allocator),
attached_to: CloneIn::clone_in(&self.attached_to, allocator),
preceded_by_newline: CloneIn::clone_in(&self.preceded_by_newline, allocator),
followed_by_newline: CloneIn::clone_in(&self.followed_by_newline, allocator),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/oxc_ast/src/generated/derive_content_eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4226,9 +4226,9 @@ impl ContentEq for CommentPosition {

impl ContentEq for Comment {
fn content_eq(&self, other: &Self) -> bool {
ContentEq::content_eq(&self.kind, &other.kind)
ContentEq::content_eq(&self.attached_to, &other.attached_to)
&& ContentEq::content_eq(&self.kind, &other.kind)
&& ContentEq::content_eq(&self.position, &other.position)
&& ContentEq::content_eq(&self.attached_to, &other.attached_to)
&& ContentEq::content_eq(&self.preceded_by_newline, &other.preceded_by_newline)
&& ContentEq::content_eq(&self.followed_by_newline, &other.followed_by_newline)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_ast/src/generated/derive_content_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,9 +2388,9 @@ impl ContentHash for CommentPosition {

impl ContentHash for Comment {
fn content_hash<H: Hasher>(&self, state: &mut H) {
ContentHash::content_hash(&self.attached_to, state);
ContentHash::content_hash(&self.kind, state);
ContentHash::content_hash(&self.position, state);
ContentHash::content_hash(&self.attached_to, state);
ContentHash::content_hash(&self.preceded_by_newline, state);
ContentHash::content_hash(&self.followed_by_newline, state);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/oxc_ast/src/trivia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub fn has_comments_between(comments: &[Comment], span: Span) -> bool {
}

/// Double-ended iterator over a range of comments, by starting position.
pub struct CommentsRange<'a> {
comments: &'a [Comment],
pub struct CommentsRange<'c> {
comments: &'c [Comment],
range: (Bound<u32>, Bound<u32>),
current_start: usize,
current_end: usize,
}

impl<'a> CommentsRange<'a> {
fn new(comments: &'a [Comment], start: Bound<u32>, end: Bound<u32>) -> Self {
impl<'c> CommentsRange<'c> {
fn new(comments: &'c [Comment], start: Bound<u32>, end: Bound<u32>) -> Self {
// Directly skip all comments that are already known to start
// outside the requested range.
let partition_start = {
Expand Down
51 changes: 34 additions & 17 deletions crates/oxc_language_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct Backend {
server_linter: RwLock<ServerLinter>,
diagnostics_report_map: DashMap<String, Vec<DiagnosticReport>>,
options: Mutex<Options>,
gitignore_glob: Mutex<Option<Gitignore>>,
gitignore_glob: Mutex<Vec<Gitignore>>,
}
#[derive(Debug, Serialize, Deserialize, Default, PartialEq, PartialOrd, Clone, Copy)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -303,19 +303,28 @@ impl Backend {

let ignore_file_glob_set = builder.build().unwrap();

let mut gitignore_builder = ignore::gitignore::GitignoreBuilder::new(uri.path());
let walk = ignore::WalkBuilder::new(uri.path())
.ignore(true)
.hidden(false)
.git_global(false)
.build();
for entry in walk.flatten() {
if ignore_file_glob_set.is_match(entry.path()) {
gitignore_builder.add(entry.path());
.build()
.flatten();

let mut gitignore_globs = self.gitignore_glob.lock().await;
for entry in walk {
let ignore_file_path = entry.path();
if !ignore_file_glob_set.is_match(ignore_file_path) {
continue;
}
}

*self.gitignore_glob.lock().await = gitignore_builder.build().ok();
if let Some(ignore_file_dir) = ignore_file_path.parent() {
let mut builder = ignore::gitignore::GitignoreBuilder::new(ignore_file_dir);
builder.add(ignore_file_path);
if let Ok(gitignore) = builder.build() {
gitignore_globs.push(gitignore);
}
}
}
}

#[allow(clippy::ptr_arg)]
Expand Down Expand Up @@ -381,15 +390,23 @@ impl Backend {
if !uri.path().starts_with(root_uri.path()) {
return false;
}
let Some(ref gitignore_globs) = *self.gitignore_glob.lock().await else {
return false;
};
let path = PathBuf::from(uri.path());
let ignored = gitignore_globs.matched_path_or_any_parents(&path, path.is_dir()).is_ignore();
if ignored {
debug!("ignored: {uri}");
let gitignore_globs = &(*self.gitignore_glob.lock().await);
for gitignore in gitignore_globs {
if let Ok(uri_path) = uri.to_file_path() {
if !uri_path.starts_with(gitignore.path()) {
continue;
}

let path = PathBuf::from(uri.path());
let ignored =
gitignore.matched_path_or_any_parents(&path, path.is_dir()).is_ignore();
if ignored {
debug!("ignored: {uri}");
return true;
}
}
}
ignored
false
}
}

Expand All @@ -409,7 +426,7 @@ async fn main() {
server_linter: RwLock::new(server_linter),
diagnostics_report_map,
options: Mutex::new(Options::default()),
gitignore_glob: Mutex::new(None),
gitignore_glob: Mutex::new(vec![]),
})
.finish();

Expand Down
27 changes: 27 additions & 0 deletions crates/oxc_linter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ All notable changes to this package will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project does not adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) until v1.0.0.

## [0.10.3] - 2024-10-26

- 90c786c regular_expression: [**BREAKING**] Support ES2025 Duplicated named capture groups (#6847) (leaysgur)

- 8032813 regular_expression: [**BREAKING**] Migrate to new regexp parser API (#6741) (leaysgur)

### Features

- a73c5af linter: Add fixer for `jsx-a11y/no-access-key` rule (#6781) (Tapan Prakash)
- 2aa763c linter: Warn unmatched rule names (#6782) (Tapan Prakash)
- 0acca58 linter: Support `--print-config all` to print config file for project (#6579) (mysteryven)

### Bug Fixes

- f49b3e2 linter: `react/iframe-missing-sandbox` ignores vanilla JS APIs (#6872) (DonIsaac)
- 54a5032 linter: Correct false positive in `no-duplicates` (#6748) (dalaoshu)
- a47c70e minifier: Fix remaining runtime bugs (#6855) (Boshen)

### Documentation

- 3923e63 linter: Add schema to config examples (#6838) (Dmitry Zakharov)

### Refactor

- a148023 linter: Dereference IDs as soon as possible (#6821) (overlookmotel)
- 423d54c rust: Remove the annoying `clippy::wildcard_imports` (#6860) (Boshen)

## [0.10.2] - 2024-10-22

- 1248557 ast: [**BREAKING**] Remove `AstKind::FinallyClause` (#6744) (Boshen)
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "oxc_linter"
version = "0.10.2"
version = "0.10.3"
authors.workspace = true
categories.workspace = true
edition.workspace = true
Expand Down
32 changes: 32 additions & 0 deletions crates/oxc_linter/src/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ pub fn nth_outermost_paren_parent<'a, 'b>(
.filter(|parent| !matches!(parent.kind(), AstKind::ParenthesizedExpression(_)))
.nth(n)
}

/// Iterate over parents of `node`, skipping nodes that are also ignored by
/// [`Expression::get_inner_expression`].
pub fn iter_outer_expressions<'a, 's>(
Expand Down Expand Up @@ -424,3 +425,34 @@ pub fn get_function_like_declaration<'b>(

decl.id.get_binding_identifier()
}

/// Get the first identifier reference within a member expression chain or
/// standalone reference.
///
/// For example, when called on the right-hand side of this [`AssignmentExpression`]:
/// ```ts
/// let x = a
/// // ^
/// let y = a.b.c
/// // ^
/// ```
///
/// As this function walks down the member expression chain, if no identifier
/// reference is found, it returns [`Err`] with the leftmost expression.
/// ```ts
/// let x = 1 + 1
/// // ^^^^^ Err(BinaryExpression)
/// let y = this.foo.bar
/// // ^^^^ Err(ThisExpression)
/// ```
pub fn leftmost_identifier_reference<'a, 'b: 'a>(
expr: &'b Expression<'a>,
) -> Result<&'a IdentifierReference<'a>, &'b Expression<'a>> {
match expr {
Expression::Identifier(ident) => Ok(ident.as_ref()),
Expression::StaticMemberExpression(mem) => leftmost_identifier_reference(&mem.object),
Expression::ComputedMemberExpression(mem) => leftmost_identifier_reference(&mem.object),
Expression::PrivateFieldExpression(mem) => leftmost_identifier_reference(&mem.object),
_ => Err(expr),
}
}
Loading

0 comments on commit 99b251d

Please sign in to comment.