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
7 changes: 7 additions & 0 deletions test/__fixtures__/plugins/absolute-path/prettier.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import path from 'node:path'

export default {
plugins: [
path.resolve('../../../../../config/prettier-plugins/prettier-plugin-uppercase-rocks/index.js')
]
}
1 change: 1 addition & 0 deletions test/__fixtures__/plugins/automatic/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents

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

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

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

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

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

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

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

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

9 changes: 9 additions & 0 deletions test/__fixtures__/plugins/automatic/prettier-plugin-baz.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import createPlugin from "../../../config/utils/create-plugin.cjs";

const plugin = createPlugin({
name: "baz",
print: (text) => `content from \`prettier-plugin-baz.js\` file + ${text}`,
finalNewLine: false,
});

export default plugin;

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

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

3 changes: 3 additions & 0 deletions test/__fixtures__/plugins/defaultOptions/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"plugins": ["./plugin"]
}
30 changes: 30 additions & 0 deletions test/__fixtures__/plugins/defaultOptions/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
},
],
defaultOptions: {
tabWidth: 8,
bracketSpacing: false,
},
parsers: {
"foo-parser": {
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print: (path, options) =>
JSON.stringify({
tabWidth: options.tabWidth,
bracketSpacing: options.bracketSpacing,
}),
},
},
};
1 change: 1 addition & 0 deletions test/__fixtures__/plugins/extensions/file.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents
24 changes: 24 additions & 0 deletions test/__fixtures__/plugins/extensions/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
},
],
parsers: {
"foo-parser": {
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print(path) {
return ["!", path.getValue().text];
},
},
},
};
24 changes: 24 additions & 0 deletions test/__fixtures__/plugins/extensions2/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

module.exports = {
languages: [
{
name: "bar",
parsers: ["bar-parser"],
extensions: [".bar"],
},
],
parsers: {
"bar-parser": {
parse: (text) => ({ text }),
astFormat: "bar-ast",
},
},
printers: {
"bar-ast": {
print(path) {
return ["!", path.getValue().text];
},
},
},
};
1 change: 1 addition & 0 deletions test/__fixtures__/plugins/flushLineSuffix/file.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents
25 changes: 25 additions & 0 deletions test/__fixtures__/plugins/flushLineSuffix/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
},
],
parsers: {
"foo-parser": {
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print(path) {
// TODO[@fisker]: Use `lineSuffix` after we support ESM plugin
return { type: "line-suffix", contents: path.getValue().text.trim() };
},
},
},
};
4 changes: 4 additions & 0 deletions test/__fixtures__/plugins/options-string/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["./plugin.cjs"],
"fooString": "baz"
}
31 changes: 31 additions & 0 deletions test/__fixtures__/plugins/options-string/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
since: "1.0.0",
},
],
options: {
fooString: {
type: "string",
default: "bar",
description: "foo description",
},
},
parsers: {
"foo-parser": {
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print: (path, options) =>
options.fooString ? `foo:${options.fooString}` : path.getValue().text,
},
},
};
4 changes: 4 additions & 0 deletions test/__fixtures__/plugins/options/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"plugins": ["./plugin.cjs"],
"fooOption": "baz"
}
41 changes: 41 additions & 0 deletions test/__fixtures__/plugins/options/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
since: "1.0.0",
},
],
options: {
fooOption: {
type: "choice",
default: "bar",
description: "foo description",
choices: [
{
value: "bar",
description: "bar description",
},
{
value: "baz",
description: "baz description",
},
],
},
},
parsers: {
"foo-parser": {
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print: (path, options) =>
options.fooOption ? `foo:${options.fooOption}` : path.getValue().text,
},
},
};
1 change: 1 addition & 0 deletions test/__fixtures__/plugins/preprocess/file.foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
contents
24 changes: 24 additions & 0 deletions test/__fixtures__/plugins/preprocess/plugin.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

module.exports = {
languages: [
{
name: "foo",
parsers: ["foo-parser"],
extensions: [".foo"],
since: "1.0.0",
},
],
parsers: {
"foo-parser": {
preprocess: (text) => `preprocessed:${text}`,
parse: (text) => ({ text }),
astFormat: "foo-ast",
},
},
printers: {
"foo-ast": {
print: (path) => path.getValue().text,
},
},
};
Empty file.
Loading