Skip to content

Commit db409b7

Browse files
committed
fix: added checks for prettier, for the eslint, stylelint and markdown lint group
Signed-off-by: prisis <[email protected]>
1 parent 1f951e8 commit db409b7

File tree

7 files changed

+135
-86
lines changed

7 files changed

+135
-86
lines changed

.github/settings.yml

+102-48
Original file line numberDiff line numberDiff line change
@@ -35,75 +35,129 @@ branches:
3535
# https://docs.github.com/en/rest/reference/issues#update-a-label
3636

3737
labels:
38-
- name: "Added"
39-
description: "Changelog Added"
40-
color: "90db3f"
38+
- name: "s: needs decision"
39+
description: "Needs team/maintainer decision"
40+
color: "C453C3"
4141

42-
- name: "Changed"
43-
description: "Changelog Changed"
42+
- name: "s: needs proposal"
43+
description: "Changelog Fixed"
4444
color: "fbca04"
4545

46-
- name: "Dependency update"
47-
description: "Pull requests that update a dependency file"
48-
color: "e1f788"
46+
- name: "s: needs design"
47+
description: "Changelog Fixed"
48+
color: "fbca04"
4949

50-
- name: "Deprecated"
51-
description: "Changelog Deprecated"
52-
color: "1d76db"
50+
- name: "s: accepted"
51+
description: "Accepted feature / Confirmed bug"
52+
color: "0E8A16"
5353

54-
- name: "Duplicate"
55-
color: "000000"
54+
- name: "s: awaiting more info"
55+
description: "Additional information are requested"
56+
color: "B76026"
5657

57-
- name: "Enhancement"
58-
color: "d7e102"
58+
- name: "s: invalid"
59+
description: "This doesn't seem right"
60+
color: "E4E669"
5961

60-
- name: "Stale"
61-
color: "000000"
62+
- name: "s: on hold"
63+
description: "Blocked by something or frozen to avoid conflicts"
64+
color: "A03F0B"
6265

63-
- name: "Fixed"
64-
description: "Changelog Fixed"
65-
color: "9ef42e"
66+
- name: "s: pending triage"
67+
description: "Pending Triage"
68+
color: "dddddd"
6669

67-
- name: "Removed"
68-
description: "Changelog Removed"
69-
color: "e99695"
70+
- name: "s: waiting for user interest"
71+
description: "Waiting for more users interested in this feature"
72+
color: "4B02CE"
7073

71-
- name: "Security"
72-
description: "Changelog Security"
73-
color: "ed3e3b"
74+
- name: "wontfix"
75+
description: "This will not be worked on"
76+
color: "ffffff"
7477

75-
- name: "Status: Good first issue"
76-
color: "d7e102"
78+
- name: "question"
79+
description: "Further information is requested"
80+
color: "956692"
7781

78-
- name: "Status: Help wanted"
79-
color: "85d84e"
82+
- name: "p: 1-normal"
83+
description: "Nothing urgent"
84+
color: "BFDADC"
8085

81-
- name: "Status: Needs Work"
82-
color: "fad8c7"
86+
- name: "p: 2-high"
87+
description: "Fix main branch"
88+
color: "FF4d4d"
8389

84-
- name: "Status: Waiting for feedback"
85-
color: "fef2c0"
90+
- name: "p: 3-urgent"
91+
description: "Fix and release ASAP"
92+
color: "FF0000"
8693

87-
- name: "Type: BC Break"
88-
color: "b60205"
94+
- name: "needs test"
95+
description: "More tests are needed"
96+
color: "FAF1A2"
8997

90-
- name: "Type: Bug"
91-
color: "b60205"
98+
- name: "needs rebase"
99+
description: "There is a merge conflict"
100+
color: "32345B"
92101

93-
- name: "Type: Critical"
94-
color: "ff8c00"
102+
- name: "c: bug"
103+
description: "Something isn't working"
104+
color: "FFA500"
95105

96-
- name: "Type: RFC"
97-
color: "fbca04"
106+
- name: "c: chore"
107+
description: "PR that doesn't affect the runtime behavior"
108+
color: "40E0D0"
109+
110+
- name: "c: docs"
111+
description: "Improvements or additions to documentation"
112+
color: "FFFF00"
113+
114+
- name: "c: dependencies"
115+
description: "Pull requests that adds/updates a dependency"
116+
color: "AFEEEE"
117+
118+
- name: "c: feature"
119+
description: "Request for new feature"
120+
color: "2878FF"
121+
122+
- name: "c: infra"
123+
description: "Changes to our infrastructure or project setup"
124+
color: "2c3e50"
125+
126+
- name: "c: refactor"
127+
description: "PR that affects the runtime behavior, but doesn't add new features or fixes bugs"
128+
color: "40E0D0"
129+
130+
- name: "c: security"
131+
description: "Indicates a vulnarability"
132+
color: "B60205"
133+
134+
- name: "deprecation"
135+
description: "A deprecation was made in the PR"
136+
color: "C5DEF5"
137+
138+
- name: "do NOT merge yet"
139+
description: "Do not merge this PR into the target branch yet"
140+
color: "FF0205"
141+
142+
- name: "duplicate"
143+
description: "Duplicate of another issue/PR"
144+
color: "fef2c0"
145+
146+
- name: "good first issue"
147+
description: "Good for newcomers"
148+
color: "7057ff"
98149

99-
- name: "Type: Unconfirmed"
100-
color: "444444"
150+
- name: "has workaround"
151+
description: "Workaround provided or linked"
152+
color: "4049AD"
101153

102-
- name: "Type: Wontfix"
103-
color: "000000"
154+
- name: "help wanted"
155+
description: "Extra attention is needed"
156+
color: "008672"
104157

105-
- name: "semantic-release"
106-
color: "ff0000"
158+
- name: "breaking change"
159+
description: "Cannot be merged when next version is not a major release"
160+
color: "B05D08"
107161

108162
# https://docs.github.com/en/rest/reference/repos#update-a-repository
109163

packages/lint-staged-config/src/config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ const groups: Groups = [
2020
{
2121
config: eslintConfig,
2222
configName: "eslint",
23-
dependencies: ["prettier", "eslint"],
23+
dependencies: ["eslint"],
2424
},
2525
{
2626
config: jsonConfig,
2727
configName: "json",
28-
dependencies: ["prettier", "sort-package-json"],
28+
dependencies: ["prettier"],
2929
},
3030
{
3131
config: markdownConfig,
3232
configName: "markdown",
33-
dependencies: ["prettier", "markdownlint-cli", "markdownlint-cli2"],
33+
dependencies: ["markdownlint-cli", "markdownlint-cli2"],
3434
},
3535
{
3636
config: secretlintConfig,

packages/lint-staged-config/src/global.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@ declare global {
1212
var anolilabLintStagedPackageJsonConfig: undefined | { [key: string]: boolean | undefined };
1313

1414
var anolilabLintStagedPackageManager: undefined | "pnpm" | "npm" | "yarn";
15+
16+
var hasAnolilabLintStagedPrettier: undefined | boolean;
1517
}

packages/lint-staged-config/src/groups/eslint/index.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Config } from "lint-staged";
33

44
import concatFiles from "../../utils/concat-files";
55
import getPackageManager from "../../utils/get-package-manager";
6+
import consoleLog from "../../utils/logger";
67
import createEslintCommands from "./create-eslint-commands";
78

89
const extensions = ["cjs", "js", "mjs", "cts", "ts", "mts", "yml", "yaml", "jsx", "tsx", "mdx", "toml"];
@@ -19,10 +20,16 @@ if (!global.hasAnolilabLintStagedMarkdownCli && !global.hasAnolilabLintStagedMar
1920
extensions.push("md");
2021
}
2122

23+
if (!global.hasAnolilabLintStagedPrettier) {
24+
global.hasAnolilabLintStagedPrettier = hasDependency("prettier") || hasDevDependency("prettier");
25+
26+
consoleLog("Prettier was found inside your package.json. It will be used to format your files, before eslint is executed.");
27+
}
28+
2229
const group: Config = {
2330
[`**/*.{${["json", "json5", "jsonc"].join(",")}}`]: async (filenames: string[]) => [...(await createEslintCommands(filenames))],
2431
[`**/*.{${[extensions].join(",")}}`]: async (filenames: string[]) => [
25-
`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,
32+
...(global.hasAnolilabLintStagedPrettier ? [`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`] : []),
2633
...(await createEslintCommands(filenames)),
2734
],
2835
};

packages/lint-staged-config/src/groups/markdown.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,33 @@ import type { Config } from "lint-staged";
33

44
import concatFiles from "../utils/concat-files";
55
import getPackageManager from "../utils/get-package-manager";
6+
import consoleLog from "../utils/logger";
67

78
if (!global.hasAnolilabLintStagedMarkdownCli) {
89
global.hasAnolilabLintStagedMarkdownCli = hasDependency("markdownlint-cli") || hasDevDependency("markdownlint-cli");
910
}
11+
1012
if (!global.hasAnolilabLintStagedMarkdownCli2) {
1113
global.hasAnolilabLintStagedMarkdownCli2 = hasDependency("markdownlint-cli2") || hasDevDependency("markdownlint-cli2");
1214
}
1315

16+
if (!global.hasAnolilabLintStagedPrettier) {
17+
global.hasAnolilabLintStagedPrettier = hasDependency("prettier") || hasDevDependency("prettier");
18+
19+
consoleLog("Prettier was found inside your package.json. It will be used to format your markdown files.");
20+
}
21+
1422
const group: Config = {
1523
"**/*.md": (filenames: string[]) => [
16-
`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`,
24+
...(global.hasAnolilabLintStagedPrettier ? [`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`] : []),
1725
...(global.hasAnolilabLintStagedMarkdownCli
1826
? [`${getPackageManager()} exec markdownlint --fix --ignore '**/node_modules/**' --ignore '**/CHANGELOG.md' ${concatFiles(filenames)}`]
1927
: []),
2028
...(global.hasAnolilabLintStagedMarkdownCli2
2129
? [`${getPackageManager()} exec markdownlint-cli2 --fix '!**/node_modules/**' '!**/CHANGELOG.md' ${concatFiles(filenames)}`]
2230
: []),
2331
],
24-
"**/*.mdx": (filenames) => [`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`],
32+
"**/*.mdx": (filenames) => [...(global.hasAnolilabLintStagedPrettier ? [`${getPackageManager()} exec prettier --write ${concatFiles(filenames)}`] : [])],
2533
};
2634

2735
export default group;

packages/lint-staged-config/src/groups/stylesheets.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1+
import { hasDependency, hasDevDependency } from "@anolilab/package-json-utils";
12
import type { Config } from "lint-staged";
23

34
import concatFiles from "../utils/concat-files";
45
import getPackageManager from "../utils/get-package-manager";
6+
import consoleLog from "../utils/logger";
7+
8+
if (!global.hasAnolilabLintStagedPrettier) {
9+
global.hasAnolilabLintStagedPrettier = hasDependency("prettier") || hasDevDependency("prettier");
10+
11+
consoleLog("Prettier was found inside your package.json. It will be used to format your files, before stylelint is executed.");
12+
}
513

614
const group: Config = {
715
[`**/*.{${["css", "sass", "scss", "less"].join(",")}}`]: (filenames: string[]) => [
8-
`${getPackageManager()} exec prettier --ignore-unknown --write ${concatFiles(filenames)}`,
16+
...(global.hasAnolilabLintStagedPrettier ? [`${getPackageManager()} exec prettier --ignore-unknown --write ${concatFiles(filenames)}`] : []),
917
`${getPackageManager()} exec stylelint --fix`,
1018
],
1119
};

pnpm-lock.yaml

+1-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)