Skip to content

Commit

Permalink
prettierx ci: support npm dev-package-test
Browse files Browse the repository at this point in the history
(in prettierx-rebase-branch-001 version branch)

using file link for internal eslint plugin in package.json

(link: paths are only supported by Yarn)

based on a proposal in:

- #603

and update tests/integration/env.js to use fork package name
from package.json

Co-authored-by: Adaline Valentina Simonian <[email protected]>
Co-authored-by: Christopher J. Brody <[email protected]>
  • Loading branch information
brodycj and adalinesimonian committed Jun 28, 2021
1 parent f7ede4b commit f6ed67f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"eslint-formatter-friendly": "7.0.0",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jest": "24.3.6",
"eslint-plugin-prettier-internal-rules": "link:scripts/tools/eslint-plugin-prettier-internal-rules",
"eslint-plugin-prettier-internal-rules": "file:./scripts/tools/eslint-plugin-prettier-internal-rules",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-regexp": "0.12.1",
"eslint-plugin-unicorn": "33.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,20 @@ module.exports = {
},
create(context) {
const fileName = context.getFilename();
// [prettierx]: support npm dev install
const parentDir = path.basename(path.resolve(__dirname, ".."));
const isLinked = parentDir !== "node_modules";
const projectRoot = isLinked ? "../../.." : "../..";

const ignored = new Map(
context.options.map((option) => {
if (typeof option === "string") {
option = { file: option };
}
const { file, functions } = option;
return [
path.join(__dirname, "../../..", file),
// [prettierx]: support npm dev install
path.join(__dirname, projectRoot, file),
functions ? new Set(functions) : true,
];
})
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
const path = require("path");
const isProduction = process.env.NODE_ENV === "production";
const { PRETTIER_DIR } = process.env;
const { bin } = require(path.join(PRETTIER_DIR, "package.json"));
// [prettierx] get fork package name from package.json
const { bin, name } = require(path.join(PRETTIER_DIR, "package.json"));
const prettierCli = path.join(
PRETTIER_DIR,
typeof bin === "object" ? bin.prettier : bin
// [prettierx] use fork package name from package.json
typeof bin === "object" ? bin[name] : bin
);

const thirdParty = isProduction
Expand Down
5 changes: 2 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2927,9 +2927,8 @@ [email protected]:
dependencies:
"@typescript-eslint/experimental-utils" "^4.0.1"

"eslint-plugin-prettier-internal-rules@link:scripts/tools/eslint-plugin-prettier-internal-rules":
version "0.0.0"
uid ""
"eslint-plugin-prettier-internal-rules@file:./scripts/tools/eslint-plugin-prettier-internal-rules":
version "1.0.3"

[email protected]:
version "7.24.0"
Expand Down

0 comments on commit f6ed67f

Please sign in to comment.