Skip to content

Commit

Permalink
Introduce new linting setup (#1341)
Browse files Browse the repository at this point in the history
* Setup new scripts stuff

* Run lint & prettier - again
  • Loading branch information
krzysztofzuraw authored Oct 10, 2024
1 parent c432da0 commit ee6cb1a
Show file tree
Hide file tree
Showing 56 changed files with 988 additions and 588 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.docusaurus/
docusaurus.config.js
build/
docs/
examples/
template/
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"extends": ["eslint:recommended", "plugin:react/recommended"],
"overrides": [
{
"files": ["*.mdx"],
"extends": "plugin:mdx/recommended"
}
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": "latest",
"sourceType": "module"
},
"env": {
"browser": true,
"node": true,
"es6": true
},
"rules": {
"react/prop-types": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
"no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
]
},
"plugins": ["import", "simple-import-sort", "react"],
"settings": {
"mdx/code-blocks": true,
"react": {
"version": "detect"
}
}
}
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- main
pull_request:

env:
HUSKY: 0

jobs:
build:
runs-on: ubuntu-22.04
Expand All @@ -19,4 +22,6 @@ jobs:

- run: npm ci

- run: npm run lint

- run: npm run build
5 changes: 4 additions & 1 deletion .github/workflows/update-api-reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# schedule:
# - cron: "0 20 * * 1-5" # workdays at 20:00

env:
HUSKY: 0

jobs:
check_saleor_release:
name: Update API reference based on the latest Saleor release
Expand Down Expand Up @@ -42,7 +45,7 @@ jobs:
run: npm run update-api-reference

- name: Lint changes
run: npx pretty-quick
run: npm run lint

- name: Show changed files
run: git status
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/update-cli-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
# schedule:
# - cron: "10 20 * * 1-5" # workdays at 20:10

env:
HUSKY: 0

jobs:
check_saleor_release:
name: Update CLI docs
Expand Down Expand Up @@ -35,7 +38,7 @@ jobs:
- run: npm ci

- name: Lint changes
run: npx pretty-quick
run: npm run lint

- name: Show changed files
run: git status
Expand Down
16 changes: 8 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
.*
!.circleci
!.dockerignore
!.github
!.husky
!.vscode
!.remarkrc
!.prettierignore
!.nvmrc
!.eslintignore
!.eslintrc
!.gitignore
!.lintstagedrc
!.prettierrc
!.prettierignore

node_modules
node_modules/

build/
.vercel

scripts/sitemap_new.xml
scripts/sitemap_old.xml
vercel2.json
.vercel/
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/usr/bin/env sh

npx pretty-quick --staged
npm run lint
pnpm lint-staged
5 changes: 5 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/lintstagedrc.schema.json",
"*.{js,ts,tsx,jsx}": "eslint --cache --fix",
"*": "prettier --write --ignore-unknown"
}
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/*.mdx
build/
.docusaurus/
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://json.schemastore.org/prettierrc.json",
"singleQuote": false
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import React from "react";
import styles from "./AppMetadata.module.css";
import ExternalLinkIcon from "../../static/assets/icons/external-link.svg";

type Props = {
minSaleorVersion: string;
roadmapUrl?: string;
githubUrl?: string;
};
import ExternalLinkIcon from "../../static/assets/icons/external-link.svg";
import styles from "./AppMetadata.module.css";

export const AppMetadata = ({
minSaleorVersion,
roadmapUrl,
githubUrl,
}: Props) => {
export const AppMetadata = ({ minSaleorVersion, roadmapUrl, githubUrl }) => {
return (
<div className={styles.root}>
<span>
Expand Down
2 changes: 1 addition & 1 deletion components/Apps/Apps.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from "@docusaurus/Link";
import React from "react";

import Adyen from "../../static/img/apps/adyen.svg";
import CRM from "../../static/img/apps/app-crm.svg";
import Invoices from "../../static/img/apps/app-invoices.svg";
Expand All @@ -9,7 +10,6 @@ import CMS from "../../static/img/apps/cms-hub.svg";
import Notification from "../../static/img/apps/notification-hub.svg";
import Search from "../../static/img/apps/search-hub.svg";
import Segment from "../../static/img/apps/segment.svg";

import s from "./apps.module.css";

const Shell = ({ color, title, children, href = "" }) => {
Expand Down
16 changes: 9 additions & 7 deletions components/AskAI/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ const AskAI = () => {
const parts = startText.split(STREAM_SEPARATOR);
try {
refs = JSON.parse(parts[0]);
} catch {}
} catch {
/* empty */
}
setAnswer((prev) => prev + parts[1]);
didHandleHeader = true;
}
Expand Down Expand Up @@ -304,10 +306,10 @@ const AskAI = () => {
</div>
</div>

<footer class="DocSearch-Footer">
<ul class="DocSearch-Commands">
<footer className="DocSearch-Footer">
<ul className="DocSearch-Commands">
<li>
<kbd class="DocSearch-Commands-Key">
<kbd className="DocSearch-Commands-Key">
<svg
width="15"
height="15"
Expand All @@ -325,10 +327,10 @@ const AskAI = () => {
</g>
</svg>
</kbd>
<span class="DocSearch-Label">to select</span>
<span className="DocSearch-Label">to select</span>
</li>
<li>
<kbd class="DocSearch-Commands-Key">
<kbd className="DocSearch-Commands-Key">
<svg
width="15"
height="15"
Expand All @@ -346,7 +348,7 @@ const AskAI = () => {
</g>
</svg>
</kbd>
<span class="DocSearch-Label">to close</span>
<span className="DocSearch-Label">to close</span>
</li>
</ul>
</footer>
Expand Down
5 changes: 2 additions & 3 deletions components/Feedback/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState, useEffect } from "react";
import { v4 as uuid } from "uuid";

import useIsBrowser from "@docusaurus/useIsBrowser";
import React, { useEffect, useState } from "react";
import { v4 as uuid } from "uuid";

import styles from "./styles.module.css";

Expand Down
1 change: 0 additions & 1 deletion components/Figure/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";

import styles from "./styles.module.css";
import Image from "";

const Figure = ({ src, alt }) => {
return <img src={src} className={styles.figure} alt={alt} />;
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/TEMPLATE.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: APP NAME
sidebar_position: 3
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/adyen/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1
title: Adyen
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";
import { Mail } from "lucide-react";

<AppMetadata minSaleorVersion="3.17" />
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/avatax/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1
title: AvaTax
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.19"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/cms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: CMS
sidebar_position: 4
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/crm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: CRM
sidebar_position: 3
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1
title: Emails and Messages
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/invoices.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Invoices
sidebar_position: 4
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/product-feed.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Product Feed
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Search
sidebar_position: 5
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/segment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Twilio Segment
sidebar_position: 3
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.14"
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/app-store/apps/smtp/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sidebar_position: 1
title: SMTP
---

import { AppMetadata } from "/components/AppMetadata/AppMetadata.tsx";
import { AppMetadata } from "/components/AppMetadata/AppMetadata.jsx";

<AppMetadata
minSaleorVersion="3.19"
Expand Down
2 changes: 1 addition & 1 deletion examples/snippets/collections/CollectionList.query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ query CollectionList {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ query CollectionListWithProducts {
}
}
}
}
}
2 changes: 1 addition & 1 deletion examples/snippets/products/ProductByID.query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ query ProductByID($id: ID!) {
name
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ query ProductByID($id: ID!) {
name
}
}
}
}
2 changes: 1 addition & 1 deletion examples/snippets/products/SimpleProductList.query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ query ProductGetTwelveElements {
}
}
}
}
}
Loading

0 comments on commit ee6cb1a

Please sign in to comment.