Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/oxlint/test/fixtures/bom/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assert from "node:assert";

import type { Plugin } from "#oxlint/plugins";

const plugin: Plugin = {
Expand All @@ -7,13 +9,18 @@ const plugin: Plugin = {
rules: {
bom: {
create(context) {
// Check file has not been formatted by accident.
// We want the fixture files not to have trailing whitespace to check diagnostics at very end of file.
const sourceText = context.sourceCode.text;
assert(sourceText.endsWith(";"), "Fixture file has been formatted");

return {
Program(node) {
context.report({
message:
"\n" +
`hasBOM: ${context.sourceCode.hasBOM}\n` +
`sourceText: ${JSON.stringify(context.sourceCode.text)}\n` +
`sourceText: ${JSON.stringify(sourceText)}\n` +
`Program span: ${node.start}-${node.end}`,
node,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/fixes/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ let h = 8;
let i = 9;
let j = 10;

debugger;
debugger;
1 change: 0 additions & 1 deletion apps/oxlint/test/fixtures/fixes/fix.snap.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@ let granular = 9;
let cowabunga = 10;



```
7 changes: 7 additions & 0 deletions apps/oxlint/test/fixtures/fixes/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import assert from "node:assert";

import type { Diagnostic, Node, Plugin, Rule } from "#oxlint/plugins";

const rule: Rule = {
meta: {
fixable: "code",
},
create(context) {
// Check file has not been formatted by accident.
// We want the fixture files not to have trailing whitespace to check fixes at very end of file.
const sourceText = context.sourceCode.text;
assert(!sourceText.endsWith("\n"), "Fixture file has been formatted");

let debuggerCount = 0;
return {
DebuggerStatement(node) {
Expand Down
2 changes: 1 addition & 1 deletion apps/oxlint/test/fixtures/suggestions/files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ let i = 9;
let j = 10;
let k = 11;

debugger;
debugger;
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ let cowabunga = 10;
let kaboom = 11;



```
7 changes: 7 additions & 0 deletions apps/oxlint/test/fixtures/suggestions/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import assert from "node:assert";

import type { Node, Plugin, Rule, Suggestion } from "#oxlint/plugins";

const rule: Rule = {
meta: {
hasSuggestions: true,
},
create(context) {
// Check file has not been formatted by accident.
// We want the fixture files not to have trailing whitespace to check suggestions at very end of file.
const sourceText = context.sourceCode.text;
assert(!sourceText.endsWith("\n"), "Fixture has been formatted");

let debuggerCount = 0;
return {
DebuggerStatement(node) {
Expand Down
2 changes: 2 additions & 0 deletions oxfmtrc.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"**/fixtures/**",
"!apps/oxlint/test/fixtures/**",
"apps/oxlint/test/fixtures/bom/files/**",
"apps/oxlint/test/fixtures/fixes/files/**",
"apps/oxlint/test/fixtures/suggestions/files/**",
"**/dist/**",
"**/generated/**",
"**/CHANGELOG.md",
Expand Down
Loading