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
1 change: 1 addition & 0 deletions test/__fixtures__/ignore-in-subdirectories/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web1/ignore-me
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var x = 'this should not be formatted';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var x = 'this should not be formatted';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var x = 'this should be formatted';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var x = 'this should be formatted';
33 changes: 33 additions & 0 deletions test/__tests__/__snapshots__/ignore-in-subdirectories.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`formats files when executing in a subdirectory (stderr) 1`] = `""`;

exports[`formats files when executing in a subdirectory (stderr) 2`] = `""`;

exports[`formats files when executing in a subdirectory (stdout) 1`] = `"should-not-ignore.js"`;

exports[`formats files when executing in a subdirectory (stdout) 2`] = `"should-not-ignore.js"`;

exports[`formats files when executing in a subdirectory (write) 1`] = `[]`;

exports[`formats files when executing in a subdirectory (write) 2`] = `[]`;

exports[`formats files when executing in a subdirectory and using stdin (stderr) 1`] = `""`;

exports[`formats files when executing in a subdirectory and using stdin (write) 1`] = `[]`;

exports[`ignore files when executing in a subdirectory and using stdin (stderr) 1`] = `""`;

exports[`ignore files when executing in a subdirectory and using stdin (write) 1`] = `[]`;

exports[`ignores files when executing in a subdirectory (stderr) 1`] = `""`;

exports[`ignores files when executing in a subdirectory (stderr) 2`] = `""`;

exports[`ignores files when executing in a subdirectory (stdout) 1`] = `""`;

exports[`ignores files when executing in a subdirectory (stdout) 2`] = `""`;

exports[`ignores files when executing in a subdirectory (write) 1`] = `[]`;

exports[`ignores files when executing in a subdirectory (write) 2`] = `[]`;
72 changes: 72 additions & 0 deletions test/__tests__/ignore-in-subdirectories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { runCli } from "../utils";

describe("ignores files when executing in a subdirectory", () => {
runCli("ignore-in-subdirectories/web1", [
"ignore-me/should-ignore.js",
"--ignore-path",
"../.prettierignore",
"-l",
]).test({
status: 0,
});

runCli("ignore-in-subdirectories/web1", [
"ignore-me/subdirectory/should-ignore.js",
"--ignore-path",
"../.prettierignore",
"-l",
]).test({
status: 0,
});
});

describe("formats files when executing in a subdirectory", () => {
runCli("ignore-in-subdirectories/web1", [
"should-not-ignore.js",
"--ignore-path",
"../.prettierignore",
"-l",
]).test({
status: 1,
});

runCli("ignore-in-subdirectories/web2", [
"should-not-ignore.js",
"--ignore-path",
"../.prettierignore",
"-l",
]).test({
status: 1,
});
});

describe("ignore files when executing in a subdirectory and using stdin", () => {
runCli(
"ignore-in-subdirectories/web1",
[
"--ignore-path",
"../.prettierignore",
"--stdin-filepath",
"ignore-me/example.js",
],
{
input: "hello_world( );",
},
).test({
stdout: "hello_world();",
status: 0,
});
});

describe("formats files when executing in a subdirectory and using stdin", () => {
runCli(
"ignore-in-subdirectories/web1",
["--ignore-path", "../.prettierignore", "--stdin-filepath", "example.js"],
{
input: "hello_world( );",
},
).test({
stdout: "hello_world();",
status: 0,
});
});