Skip to content

Commit e53648d

Browse files
zomarskodiakhq[bot]github-actions[bot]crowdin-bothariombalhara
authored
Linting (#2083)
* Runs yarn format * Update website * Web lint is failing * Formatting * Adds cache for dependency install * Adds linting reports for GH * Fixes artifact upload * Caching tests * Merge reports on GH actions * Linting * Fix prettier plugin conflicts * Dep fixes * Moves tailwind to monorepo package (#2091) * New Crowdin translations by Github Action (#2077) Co-authored-by: Crowdin Bot <support+bot@crowdin.com> * fix redirection to 404 page on login (#2086) Co-authored-by: Peer Richelsen <peeroke@gmail.com> * fix: update contributing (#2084) Co-authored-by: Bailey Pumfleet <pumfleet@hey.com> * Formatting * Update website Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Crowdin Bot <support+bot@crowdin.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Louis <48682663+louis-27@users.noreply.github.com> Co-authored-by: Bailey Pumfleet <pumfleet@hey.com>
1 parent 9da761b commit e53648d

16 files changed

+412
-245
lines changed

.github/workflows/lint.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,30 @@ jobs:
1515
- name: Use Node.js 14.x
1616
uses: actions/setup-node@v2
1717
with:
18-
version: 14.x
18+
node-version: 14.x
19+
cache: "yarn"
20+
cache-dependency-path: yarn.lock
1921

2022
- name: Install deps
23+
if: steps.yarn-cache.outputs.cache-hit != 'true'
2124
run: yarn
2225

2326
- name: Lint
24-
run: yarn lint
27+
run: yarn lint:report
28+
continue-on-error: true
29+
30+
- name: Merge lint reports
31+
run: jq -s '[.[]]|flatten' lint-results/*.json &> lint-results/eslint_report.json
32+
33+
- name: Annotate Code Linting Results
34+
uses: ataylorme/eslint-annotate-action@1.2.0
35+
with:
36+
repo-token: "${{ secrets.GITHUB_TOKEN }}"
37+
report-json: "lint-results/eslint_report.json"
38+
39+
- name: Upload ESLint report
40+
if: ${{ always() }}
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: lint-results
44+
path: lint-results

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@ packages/prisma/zod/*.ts
6868

6969
# Builds
7070
dist
71+
72+
# Linting
73+
lint-results

.prettierrc.js

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
module.exports = {
2-
bracketSpacing: true,
3-
bracketSameLine: true,
4-
singleQuote: false,
5-
jsxSingleQuote: false,
6-
trailingComma: "es5",
7-
semi: true,
8-
printWidth: 110,
9-
arrowParens: "always",
10-
importOrder: ["^@(calcom|ee)/(.*)$", "^@lib/(.*)$", "^@components/(.*)$", "^@(server|trpc)/(.*)$", "^[./]"],
11-
importOrderSeparation: true,
12-
plugins: [require("./merged-prettier-plugin")],
13-
};
1+
module.exports = require("./packages/config/prettier-preset");

apps/docs/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf .next",
88
"dev": "PORT=4000 next",
99
"lint": "next lint",
10+
"lint:report": "eslint . --format json --output-file ../../lint-results/docs.json",
1011
"start": "PORT=4000 next start",
1112
"build": "next build"
1213
},
@@ -21,6 +22,6 @@
2122
},
2223
"devDependencies": {
2324
"@calcom/config": "*",
24-
"eslint": "^8.9.0"
25+
"eslint": "^8.10.0"
2526
}
2627
}

apps/docs/theme.config.js

+13-31
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
export default {
2-
github: 'https://github.com/calcom/cal.com',
3-
docsRepositoryBase: 'https://github.com/calcom/cal.com/blob/main/apps/docs/pages',
4-
titleSuffix: ' | Cal.com',
5-
logo: (
6-
<h4 className="m-0">
7-
Cal.com
8-
</h4>
9-
),
1+
const themeConfig = {
2+
github: "https://github.com/calcom/cal.com",
3+
docsRepositoryBase: "https://github.com/calcom/cal.com/blob/main/apps/docs/pages",
4+
titleSuffix: " | Cal.com",
5+
logo: <h4 className="m-0">Cal.com</h4>,
106
head: (
117
<>
128
<meta name="msapplication-TileColor" content="#ffffff" />
@@ -29,23 +25,9 @@ export default {
2925
<meta name="og:image" content="https://cal.com/og-image.png" />
3026
<meta name="apple-mobile-web-app-title" content="Cal.com Docs" />
3127

32-
<link
33-
rel="apple-touch-icon"
34-
sizes="180x180"
35-
href="/apple-touch-icon.png"
36-
/>
37-
<link
38-
rel="icon"
39-
type="image/png"
40-
sizes="32x32"
41-
href="/favicon-32x32.png"
42-
/>
43-
<link
44-
rel="icon"
45-
type="image/png"
46-
sizes="16x16"
47-
href="/favicon-16x16.png"
48-
/>
28+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
29+
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
30+
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
4931
<link rel="manifest" href="/site.webmanifest" />
5032
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#000000" />
5133
<meta name="msapplication-TileColor" content="#ff0000" />
@@ -56,8 +38,8 @@ export default {
5638
prevLinks: true,
5739
nextLinks: true,
5840
footer: true,
59-
footerEditLink: 'Edit this page on GitHub',
60-
footerText: (
61-
<>© {new Date().getFullYear()} Cal.com, Inc. All rights reserved.</>
62-
),
63-
}
41+
footerEditLink: "Edit this page on GitHub",
42+
footerText: <>© {new Date().getFullYear()} Cal.com, Inc. All rights reserved.</>,
43+
};
44+
45+
export default themeConfig;

apps/web/next-i18next.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = {
2424
"zh-TW",
2525
"cs",
2626
"sr",
27-
"sv"
27+
"sv",
2828
],
2929
},
3030
localePath: path.resolve("./public/static/locales"),

apps/web/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"build": "next build",
1818
"start": "next start",
1919
"lint": "next lint",
20+
"lint:report": "eslint . --format json --output-file ../../lint-results/web.json",
2021
"lint:fix": "next lint . --ext .ts,.js,.tsx,.jsx --fix",
2122
"check-changed-files": "ts-node scripts/ts-check-changed-files.ts",
2223
"downgrade": "ts-node ee/lib/stripe/downgrade.ts"
@@ -127,7 +128,7 @@
127128
"autoprefixer": "^10.4.0",
128129
"babel-jest": "^27.3.1",
129130
"env-cmd": "10.1.0",
130-
"eslint": "^8.9.0",
131+
"eslint": "^8.10.0",
131132
"jest": "^26.0.0",
132133
"mockdate": "^3.0.5",
133134
"module-alias": "^2.2.2",

apps/web/pages/[user].tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default function User(props: inferSSRProps<typeof getServerSideProps>) {
6363
<div
6464
key={type.id}
6565
style={{ display: "flex" }}
66-
className="group hover:border-brand relative rounded-sm border border-neutral-200 bg-white hover:bg-gray-50 dark:border-0 dark:bg-neutral-900 dark:hover:border-neutral-600">
66+
className="hover:border-brand group relative rounded-sm border border-neutral-200 bg-white hover:bg-gray-50 dark:border-0 dark:bg-neutral-900 dark:hover:border-neutral-600">
6767
<ArrowRightIcon className="absolute right-3 top-3 h-4 w-4 text-black opacity-0 transition-opacity group-hover:opacity-100 dark:text-white" />
6868
{/* Don't prefetch till the time we drop the amount of javascript in [user][type] page which is impacting score for [user] page */}
6969
<Link

apps/web/pages/team/[slug].tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function TeamPage({ team }: TeamPageProps) {
3232
{team.eventTypes.map((type) => (
3333
<li
3434
key={type.id}
35-
className="group hover:border-brand relative rounded-sm border border-neutral-200 bg-white hover:bg-gray-50 dark:border-0 dark:bg-neutral-900 dark:hover:border-neutral-600">
35+
className="hover:border-brand group relative rounded-sm border border-neutral-200 bg-white hover:bg-gray-50 dark:border-0 dark:bg-neutral-900 dark:hover:border-neutral-600">
3636
<ArrowRightIcon className="absolute right-3 top-3 h-4 w-4 text-black opacity-0 transition-opacity group-hover:opacity-100 dark:text-white" />
3737
<Link href={`${team.slug}/${type.slug}`}>
3838
<a className="flex justify-between px-6 py-4">

apps/website

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
2222
"heroku-postbuild": "turbo run @calcom/web#build",
2323
"lint": "turbo run lint",
24+
"lint:report": "turbo run lint:report",
2425
"pre-commit": "lint-staged",
2526
"prepare": "husky install",
2627
"start": "turbo run start --scope=\"@calcom/web\"",
@@ -30,11 +31,9 @@
3031
"type-check": "turbo run type-check"
3132
},
3233
"devDependencies": {
33-
"@trivago/prettier-plugin-sort-imports": "2.0.4",
3434
"husky": "^7.0.1",
35-
"lint-staged": "^11.1.2",
36-
"prettier": "^2.5.1",
37-
"prettier-plugin-tailwindcss": "^0.1.6"
35+
"lint-staged": "^12.3.5",
36+
"prettier": "^2.5.1"
3837
},
3938
"dependencies": {
4039
"turbo": "latest"

merged-prettier-plugin.js packages/config/merged-prettier-plugin.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ const tailwind = require("prettier-plugin-tailwindcss");
33
const sortImports = require("@trivago/prettier-plugin-sort-imports");
44

55
const combinedFormatter = {
6-
...tailwind,
76
parsers: {
8-
...tailwind.parsers,
9-
...Object.keys(sortImports.parsers).reduce((acc, key) => {
10-
acc[key] = {
11-
...tailwind.parsers[key],
12-
preprocess(code, options) {
13-
return sortImports.parsers[key].preprocess(code, options);
14-
},
15-
};
16-
return acc;
17-
}, {}),
7+
typescript: {
8+
...tailwind.parsers.typescript,
9+
preprocess: sortImports.parsers.typescript.preprocess,
10+
},
1811
},
1912
};
2013

packages/config/package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@
44
"main": "index.js",
55
"license": "MIT",
66
"files": [
7-
"eslint-preset.js"
7+
"eslint-preset.js",
8+
"prettier-preset.js"
89
],
910
"dependencies": {
1011
"eslint-config-next": "^12.0.8",
11-
"eslint-config-prettier": "^8.3.0",
12-
"eslint-plugin-playwright": "^0.7.1",
13-
"eslint-plugin-prettier": "^3.4.0"
12+
"eslint-config-prettier": "^8.5.0",
13+
"eslint-plugin-playwright": "^0.8.0",
14+
"eslint-plugin-prettier": "^4.0.0"
1415
},
1516
"devDependencies": {
1617
"@tailwindcss/forms": "^0.5.0",
1718
"@tailwindcss/typography": "^0.5.2",
19+
"@trivago/prettier-plugin-sort-imports": "3.2.0",
20+
"prettier-plugin-tailwindcss": "^0.1.8",
21+
"prettier": "^2.5.1",
1822
"tailwindcss": "^3.0.23",
1923
"typescript": "^4.5.3"
2024
}

packages/config/prettier-preset.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
bracketSpacing: true,
3+
bracketSameLine: true,
4+
singleQuote: false,
5+
jsxSingleQuote: false,
6+
trailingComma: "es5",
7+
semi: true,
8+
printWidth: 110,
9+
arrowParens: "always",
10+
importOrder: ["^@(calcom|ee)/(.*)$", "^@lib/(.*)$", "^@components/(.*)$", "^@(server|trpc)/(.*)$", "^[./]"],
11+
importOrderSeparation: true,
12+
plugins: [require("./merged-prettier-plugin")],
13+
};

turbo.json

+5
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,13 @@
8888
"cache": false
8989
},
9090
"lint": {
91+
"cache": false,
9192
"outputs": []
9293
},
94+
"lint:report": {
95+
"cache": false,
96+
"outputs": ["lint-results"]
97+
},
9398
"start": {},
9499
"test": {
95100
"dependsOn": []

0 commit comments

Comments
 (0)