From f955a4de2a20451d71484042694b2757f6c62d0e Mon Sep 17 00:00:00 2001 From: Boshen Date: Wed, 12 Jun 2024 13:11:21 +0800 Subject: [PATCH] chore: remove trailing whitespaces for all files; add editorconfig --- .editorconfig | 2 ++ crates/oxc_linter/src/partial_loader/mod.rs | 2 +- .../src/rules/react/no_find_dom_node.rs | 4 +-- .../no_unsafe_declaration_merging.rs | 6 ++-- .../no_invalid_remove_event_listener.rs | 12 +++---- crates/oxc_linter/src/snapshots/jsx_key.snap | 1 - .../src/snapshots/max_nested_describe.snap | 1 - .../src/snapshots/no_duplicate_hooks.snap | 1 - .../src/snapshots/prefer_hooks_on_top.snap | 1 - .../src/snapshots/require_hook.snap | 1 - .../src/jsdoc/parser/jsdoc_parts.rs | 2 +- crates/oxc_traverse/scripts/lib/parse.mjs | 4 +-- tasks/coverage/parser_typescript.snap | 35 +++++++++---------- tasks/minsize/minsize.snap | 14 ++++---- .../transform_conformance/typescript.snap.md | 2 +- website/playground/symbols.js | 6 ++-- 16 files changed, 45 insertions(+), 49 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000000..ade256ee1714f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,2 @@ +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/crates/oxc_linter/src/partial_loader/mod.rs b/crates/oxc_linter/src/partial_loader/mod.rs index 63d2debf7755c..bb50a94d2daec 100644 --- a/crates/oxc_linter/src/partial_loader/mod.rs +++ b/crates/oxc_linter/src/partial_loader/mod.rs @@ -15,7 +15,7 @@ pub const LINT_PARTIAL_LOADER_EXT: &[&str] = &["vue", "astro", "svelte"]; pub struct JavaScriptSource<'a> { pub source_text: &'a str, pub source_type: SourceType, - /// The javascript source could be embedded in some file, + /// The javascript source could be embedded in some file, /// use `start` to record start offset of js block in the original file. pub start: usize, } diff --git a/crates/oxc_linter/src/rules/react/no_find_dom_node.rs b/crates/oxc_linter/src/rules/react/no_find_dom_node.rs index 41f41fe4af887..e1a55ae0925dd 100644 --- a/crates/oxc_linter/src/rules/react/no_find_dom_node.rs +++ b/crates/oxc_linter/src/rules/react/no_find_dom_node.rs @@ -81,7 +81,7 @@ fn test() { render: function() { return
Hello
; } - }); + }); ", None, ), @@ -189,7 +189,7 @@ fn test() { render() { return
Hello
; } - } + } ", None, ), diff --git a/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs b/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs index 7042e3836cd19..e9cb2823c9652 100644 --- a/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs +++ b/crates/oxc_linter/src/rules/typescript/no_unsafe_declaration_merging.rs @@ -125,7 +125,7 @@ fn test() { interface Foo { props: string; } - + function bar() { return class Foo {}; } @@ -137,7 +137,7 @@ fn test() { interface Foo { props: string; } - + (function bar() { class Foo {} })(); @@ -149,7 +149,7 @@ fn test() { declare global { interface Foo {} } - + class Foo {} ", None, diff --git a/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs b/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs index 1c9c0a10b632b..713fb02968d8b 100644 --- a/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs +++ b/crates/oxc_linter/src/rules/unicorn/no_invalid_remove_event_listener.rs @@ -170,12 +170,12 @@ fn test() { element.removeEventListener("glider-refresh", event => { // $ExpectType GliderEvent event; - + // $ExpectType boolean event.bubbles; - + event.target; - + if (event.target) { // $ExpectType Glider | undefined event.target._glider; @@ -186,12 +186,12 @@ fn test() { element.removeEventListener("glider-refresh", function (event) { // $ExpectType GliderEvent event; - + // $ExpectType boolean event.bubbles; - + event.target; - + if (event.target) { // $ExpectType Glider | undefined event.target._glider; diff --git a/crates/oxc_linter/src/snapshots/jsx_key.snap b/crates/oxc_linter/src/snapshots/jsx_key.snap index 47ebfaa4ccbaa..0a028c133d37b 100644 --- a/crates/oxc_linter/src/snapshots/jsx_key.snap +++ b/crates/oxc_linter/src/snapshots/jsx_key.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 161 expression: jsx_key --- ⚠ eslint-plugin-react(jsx-key): Missing "key" prop for element in array. diff --git a/crates/oxc_linter/src/snapshots/max_nested_describe.snap b/crates/oxc_linter/src/snapshots/max_nested_describe.snap index 7ad0e897168af..bfbc1e88780a1 100644 --- a/crates/oxc_linter/src/snapshots/max_nested_describe.snap +++ b/crates/oxc_linter/src/snapshots/max_nested_describe.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 203 expression: max_nested_describe --- ⚠ eslint-plugin-jest(max-nested-describe): Enforces a maximum depth to nested describe calls. diff --git a/crates/oxc_linter/src/snapshots/no_duplicate_hooks.snap b/crates/oxc_linter/src/snapshots/no_duplicate_hooks.snap index 9edbb6ce20db6..ce8e109b4653b 100644 --- a/crates/oxc_linter/src/snapshots/no_duplicate_hooks.snap +++ b/crates/oxc_linter/src/snapshots/no_duplicate_hooks.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 162 expression: no_duplicate_hooks --- ⚠ eslint-plugin-jest(no-duplicate-hooks): Disallow duplicate setup and teardown hooks. diff --git a/crates/oxc_linter/src/snapshots/prefer_hooks_on_top.snap b/crates/oxc_linter/src/snapshots/prefer_hooks_on_top.snap index 72d89839f691b..b584618de8b6a 100644 --- a/crates/oxc_linter/src/snapshots/prefer_hooks_on_top.snap +++ b/crates/oxc_linter/src/snapshots/prefer_hooks_on_top.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 161 expression: prefer_hooks_on_top --- ⚠ eslint-plugin-jest(prefer-hooks-on-top): Suggest having hooks before any test cases. diff --git a/crates/oxc_linter/src/snapshots/require_hook.snap b/crates/oxc_linter/src/snapshots/require_hook.snap index 3507904ae0a7d..a88a14c3d3408 100644 --- a/crates/oxc_linter/src/snapshots/require_hook.snap +++ b/crates/oxc_linter/src/snapshots/require_hook.snap @@ -1,6 +1,5 @@ --- source: crates/oxc_linter/src/tester.rs -assertion_line: 157 expression: require_hook --- ⚠ eslint-plugin-jest(require-hook): Require setup and teardown code to be within a hook. diff --git a/crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs b/crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs index 0ae598fdea580..0bbd3ba6b4987 100644 --- a/crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs +++ b/crates/oxc_semantic/src/jsdoc/parser/jsdoc_parts.rs @@ -247,7 +247,7 @@ mod test { ( " extra text -* +* ", "extra text", ), diff --git a/crates/oxc_traverse/scripts/lib/parse.mjs b/crates/oxc_traverse/scripts/lib/parse.mjs index 20eff1caf795d..afac39d607fc8 100644 --- a/crates/oxc_traverse/scripts/lib/parse.mjs +++ b/crates/oxc_traverse/scripts/lib/parse.mjs @@ -84,7 +84,7 @@ function parseStruct(name, rawName, lines, scopeArgs, filename, startLineIndex) const [, rawName, name, rawTypeName] = match, typeName = rawTypeName.replace(/<'a>/g, '').replace(/<'a, ?/g, '<'), {name: innerTypeName, wrappers} = typeAndWrappers(typeName); - + fields.push({name, typeName, rawName, rawTypeName, innerTypeName, wrappers}); } return {kind: 'struct', name, rawName, fields, scopeArgs}; @@ -144,7 +144,7 @@ function parseScopeArgs(argsStr, filename, lineIndex) { } } assert(bracketCount === 0); - + args[key] = argsStr.slice(0, index).trim(); argsStr = argsStr.slice(index + 1); if (argsStr === '') break; diff --git a/tasks/coverage/parser_typescript.snap b/tasks/coverage/parser_typescript.snap index 72611f80d5b2f..ccf63e558a5ec 100644 --- a/tasks/coverage/parser_typescript.snap +++ b/tasks/coverage/parser_typescript.snap @@ -6572,7 +6572,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × TS1108: A 'return' statement can only be used within a function body ╭─[compiler/fileWithNextLine3.ts:3:1] 2 │ // 0. It should be counted as a space and should not trigger ASI - 3 │ return…0; + 3 │ return…0; · ────── ╰──── @@ -6731,9 +6731,9 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── × Unexpected token - ╭─[compiler/incompleteDottedExpressionAtEOF.ts:2:18] + ╭─[compiler/incompleteDottedExpressionAtEOF.ts:2:17] 1 │ // used to leak __missing into error message - 2 │ var p2 = window. + 2 │ var p2 = window. ╰──── × Expected `,` but found `;` @@ -8695,7 +8695,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Unexpected token ╭─[compiler/restArgMissingName.ts:1:18] - 1 │ function sum (...) {} + 1 │ function sum (...) {} · ─ ╰──── @@ -9819,14 +9819,14 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Unexpected token ╭─[compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts:5:24] 4 │ // Incomplete call, but too many parameters. - 5 │ f `123qdawdrqw${ 1 }${ }${ + 5 │ f `123qdawdrqw${ 1 }${ }${ · ─ ╰──── × Expected `$}` but found `EOF` - ╭─[compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts:5:30] + ╭─[compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts:5:29] 4 │ // Incomplete call, but too many parameters. - 5 │ f `123qdawdrqw${ 1 }${ 2 }${ + 5 │ f `123qdawdrqw${ 1 }${ 2 }${ ╰──── × Expected `$}` but found `EOF` @@ -10570,8 +10570,8 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Constructor can't be an async method ╭─[conformance/async/es6/asyncConstructor_es6.ts:2:9] - 1 │ class C { - 2 │ async constructor() { + 1 │ class C { + 2 │ async constructor() { · ─────────── 3 │ } ╰──── @@ -13182,8 +13182,8 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╰──── × Expected `$}` but found `EOF` - ╭─[conformance/es6/templates/TemplateExpression1.ts:1:19] - 1 │ var v = `foo ${ a + ╭─[conformance/es6/templates/TemplateExpression1.ts:1:18] + 1 │ var v = `foo ${ a ╰──── × 'super' can only be used with function calls or in property accesses @@ -16352,7 +16352,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Expected `,` but found `float` ╭─[conformance/parser/ecmascript5/ErrorRecovery/ArrayLiteralExpressions/parserErrorRecoveryArrayLiteralExpression2.ts:3:2] - 2 │ + 2 │ 3 │ .7042760848999023, 1.1955541372299194, 0.19600726664066315, -0.7120069861412048]; · ────────┬──────── · ╰── `,` expected @@ -17483,20 +17483,19 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Invalid Unicode escape sequence ╭─[conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens11.ts:1:4] - 1 │ ; \ \ \ + 1 │ ; \ \ \ · ─ ╰──── × Invalid Unicode escape sequence ╭─[conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens11.ts:1:6] - 1 │ ; \ \ \ + 1 │ ; \ \ \ · ─ ╰──── × Invalid Unicode escape sequence ╭─[conformance/parser/ecmascript5/SkippedTokens/parserSkippedTokens11.ts:1:8] - 1 │ ; \ \ \ - · ─ + 1 │ ; \ \ \ ╰──── × Invalid Unicode escape sequence @@ -18335,7 +18334,7 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" × Expected `,` but found `?` ╭─[conformance/parser/ecmascript6/ShorthandPropertyAssignment/parserShorthandPropertyAssignment5.ts:2:18] 1 │ var greet = "hello"; - 2 │ var obj = { greet? }; + 2 │ var obj = { greet? }; · ┬ · ╰── `,` expected ╰──── @@ -20420,5 +20419,5 @@ Expect to Parse: "conformance/salsa/plainJSRedeclare3.ts" ╭─[conformance/types/typeParameters/typeParameterLists/varianceAnnotationsWithCircularlyReferencesError.ts:1:12] 1 │ type T1 = T1 // Error: circularly references · ── - 2 │ type T2 = T2 // Error: circularly references + 2 │ type T2 = T2 // Error: circularly references ╰──── diff --git a/tasks/minsize/minsize.snap b/tasks/minsize/minsize.snap index 6021a92635b2d..42a56a490380e 100644 --- a/tasks/minsize/minsize.snap +++ b/tasks/minsize/minsize.snap @@ -1,19 +1,19 @@ -Original -> Minified -> Gzip +Original -> Minified -> Gzip 72.14 kB -> 39.58 kB -> 10.83 kB react.development.js -173.90 kB -> 95.37 kB -> 24.37 kB moment.js +173.90 kB -> 95.37 kB -> 24.37 kB moment.js -287.63 kB -> 140.16 kB -> 39.82 kB jquery.js +287.63 kB -> 140.16 kB -> 39.82 kB jquery.js -342.15 kB -> 189.85 kB -> 55.32 kB vue.js +342.15 kB -> 189.85 kB -> 55.32 kB vue.js -544.10 kB -> 144.63 kB -> 35.31 kB lodash.js +544.10 kB -> 144.63 kB -> 35.31 kB lodash.js -555.77 kB -> 390.47 kB -> 102.94 kB d3.js +555.77 kB -> 390.47 kB -> 102.94 kB d3.js 977.19 kB -> 603.47 kB -> 138.53 kB bundle.min.js -1.25 MB -> 929.41 kB -> 189.96 kB three.js +1.25 MB -> 929.41 kB -> 189.96 kB three.js 2.14 MB -> 1.41 MB -> 217.64 kB victory.js diff --git a/tasks/transform_conformance/typescript.snap.md b/tasks/transform_conformance/typescript.snap.md index 663a7982ebc5a..f0f058d3bdb70 100644 --- a/tasks/transform_conformance/typescript.snap.md +++ b/tasks/transform_conformance/typescript.snap.md @@ -481,7 +481,7 @@ var E = (E => { × Expected `,` but found `;` ╭─[typescript/tests/cases/conformance/enums/enumErrors.ts:48:18] - 47 │ + 47 │ 48 │ postSemicolon; · ┬ · ╰── `,` expected diff --git a/website/playground/symbols.js b/website/playground/symbols.js index e7d2779486f8f..64441cda16528 100644 --- a/website/playground/symbols.js +++ b/website/playground/symbols.js @@ -14,9 +14,9 @@ */ let cacheSymbols = null /** - * - * @param {SymbolTable} symbols - * @returns + * + * @param {SymbolTable} symbols + * @returns */ export const renderSymbols = (symbols) => { const target = []