From 8ca7c53774985ed9169b761a13a89ec36cada46c Mon Sep 17 00:00:00 2001 From: soy Date: Tue, 14 May 2024 12:19:06 +0900 Subject: [PATCH 1/5] feat: add ci settings --- .github/labeler.yml | 9 +++++++++ .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/pr_title.yml | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .github/labeler.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pr_title.yml diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000..9154204 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,9 @@ +bug: + - "bug" + - "fix" +enhancement: + - "enhancement" + - "feature" +documentation: + - "docs" + - "documentation" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..147b891 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: ci + +on: + push: + branches: [main, release/*, release] + pull_request: + +jobs: + lint_test: + name: Lint and Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: lts/* + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "path=$(yarn cache dir)" >> $GITHUB_OUTPUT + - uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.path }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Run install + run: yarn install --frozen-lockfile + - name: Run lint + run: yarn lint + - name: Run test + run: yarn test \ No newline at end of file diff --git a/.github/workflows/pr_title.yml b/.github/workflows/pr_title.yml new file mode 100644 index 0000000..b7edfac --- /dev/null +++ b/.github/workflows/pr_title.yml @@ -0,0 +1,32 @@ +name: PR Title Checker + +on: + pull_request: + types: + - opened + - edited + - synchronize + - labeled + - unlabeled + +permissions: + checks: write + contents: read + pull-requests: write + +jobs: + pr_title: + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ignoreLabels: meta + subjectPattern: ^(?![A-Z]).+$ + subjectPatternError: | + The subject "{subject}" found in the pull request title "{title}" + didn't match the configured pattern. Please ensure that the subject + doesn't start with an uppercase character. \ No newline at end of file From b6178723b17591aa6c614226b9150d5d9c619e86 Mon Sep 17 00:00:00 2001 From: soy Date: Wed, 15 May 2024 01:19:42 +0900 Subject: [PATCH 2/5] fix: lint errors --- src/engines/Cesium/type.d.ts | 1 - src/mantle/data/gpx.ts | 2 +- src/mantle/evaluator/simple/expression/variableReplacer.ts | 2 -- src/mantle/evaluator/simple/index.ts | 5 ----- src/mantle/evaluator/simple/utils.ts | 1 - src/test/utils.tsx | 2 -- 6 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/engines/Cesium/type.d.ts b/src/engines/Cesium/type.d.ts index 83f98e8..a37240b 100644 --- a/src/engines/Cesium/type.d.ts +++ b/src/engines/Cesium/type.d.ts @@ -11,7 +11,6 @@ declare module "@cesium/engine" { // (...args: Parameter[]). // This cannot be fixed by augmentation but by overloading. export interface Event void = (...args: any[]) => void> { - // eslint-disable-next-line @typescript-eslint/method-signature-style raiseEvent(...arguments: Parameters): void; } diff --git a/src/mantle/data/gpx.ts b/src/mantle/data/gpx.ts index 1bd4142..ab88251 100644 --- a/src/mantle/data/gpx.ts +++ b/src/mantle/data/gpx.ts @@ -24,7 +24,7 @@ const handler = (xmlDataStr: string) => { const parseGPX = (gpxSource: string) => { const parseMethod = (gpxSource: string): Document | null => { // Verify that we are in a browser - if (typeof document == undefined) return null; + if (typeof document === "undefined") return null; const domParser = new window.DOMParser(); return domParser.parseFromString(gpxSource, "text/xml"); diff --git a/src/mantle/evaluator/simple/expression/variableReplacer.ts b/src/mantle/evaluator/simple/expression/variableReplacer.ts index 339ae6b..6d0cdd2 100644 --- a/src/mantle/evaluator/simple/expression/variableReplacer.ts +++ b/src/mantle/evaluator/simple/expression/variableReplacer.ts @@ -6,14 +6,12 @@ import { JPLiteral } from "./expression"; export const VARIABLE_PREFIX = "czm_"; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export function replaceVariables(expression: string, feature?: any): [string, JPLiteral[]] { let exp = expression; let result = ""; const literalJP: JPLiteral[] = []; let i = exp.indexOf("${"); const featureDefined = typeof feature !== "undefined"; - // eslint-disable-next-line @typescript-eslint/no-explicit-any const jsonPathCache: Record = {}; const varExpRegex = /^\$./; while (i >= 0) { diff --git a/src/mantle/evaluator/simple/index.ts b/src/mantle/evaluator/simple/index.ts index fbc15c3..7f9d89f 100644 --- a/src/mantle/evaluator/simple/index.ts +++ b/src/mantle/evaluator/simple/index.ts @@ -68,7 +68,6 @@ export function evalLayerAppearances( ); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function recursiveValEval(obj: any, layer: LayerSimple, feature?: Feature): any { return Object.fromEntries( Object.entries(obj).map(([k, v]) => { @@ -92,7 +91,6 @@ export function clearAllExpressionCaches( }); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function recursiveClear(obj: any, layer: LayerSimple | undefined, feature: Feature | undefined) { Object.entries(obj).forEach(([, v]) => { // if v is an object itself and not a null, recurse deeper @@ -115,18 +113,15 @@ function recursiveClear(obj: any, layer: LayerSimple | undefined, feature: Featu }); } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function hasExpression(e: any): e is ExpressionContainer { return typeof e === "object" && e && "expression" in e; } -// eslint-disable-next-line @typescript-eslint/no-explicit-any function hasNonExpressionObject(v: any): boolean { return typeof v === "object" && v && !("expression" in v) && !Array.isArray(v); } export function evalExpression( - // eslint-disable-next-line @typescript-eslint/no-explicit-any expressionContainer: any, layer?: LayerSimple, feature?: Feature, diff --git a/src/mantle/evaluator/simple/utils.ts b/src/mantle/evaluator/simple/utils.ts index 7bcc51b..2d765db 100644 --- a/src/mantle/evaluator/simple/utils.ts +++ b/src/mantle/evaluator/simple/utils.ts @@ -7,7 +7,6 @@ export const generateRandomString = (len: number): string => { .toLowerCase(); }; -// eslint-disable-next-line @typescript-eslint/no-explicit-any export const recursiveJSONParse = (obj: any): any => { if (typeof obj !== "object" || obj === null) { return obj; diff --git a/src/test/utils.tsx b/src/test/utils.tsx index 15c52b5..2bd2f13 100644 --- a/src/test/utils.tsx +++ b/src/test/utils.tsx @@ -33,8 +33,6 @@ const render = ( return rtlRender(ui, { wrapper: Wrapper, ...renderOptions }); }; -// eslint-disable-next-line import/export export * from "@testing-library/react"; -// eslint-disable-next-line import/export export { render }; From d5f6751ebe02fe75aa9c10391b69384524df74fc Mon Sep 17 00:00:00 2001 From: soy Date: Wed, 15 May 2024 01:21:49 +0900 Subject: [PATCH 3/5] fix: lint warnings --- example/src/main.tsx | 9 ++++----- example/vite.config.ts | 2 +- src/Map/utils.ts | 10 ++++++++-- src/engines/Cesium/utils/polygon.ts | 4 ++-- src/mantle/atoms/compute.ts | 4 ++-- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/example/src/main.tsx b/example/src/main.tsx index ff8cf01..e0a4c24 100644 --- a/example/src/main.tsx +++ b/example/src/main.tsx @@ -1,6 +1,5 @@ -import ReactDOM from 'react-dom/client' -import App from './App.tsx' +import ReactDOM from "react-dom/client"; -ReactDOM.createRoot(document.getElementById('root')!).render( - , -) +import App from "./App.tsx"; + +ReactDOM.createRoot(document.getElementById("root")!).render(); diff --git a/example/vite.config.ts b/example/vite.config.ts index 9c44d51..cde309d 100644 --- a/example/vite.config.ts +++ b/example/vite.config.ts @@ -1,5 +1,5 @@ -import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; +import { defineConfig } from "vite"; import cesium from "vite-plugin-cesium"; // https://vitejs.dev/config/ diff --git a/src/Map/utils.ts b/src/Map/utils.ts index e974c98..0c25370 100644 --- a/src/Map/utils.ts +++ b/src/Map/utils.ts @@ -20,8 +20,14 @@ export function mergeProperty(a: any, b: any) { return mergeWith( a2, b, - (s: any, v: any, _k: string | number | symbol, _obj: any, _src: any, stack: { size: number }) => - stack.size > 0 || Array.isArray(v) ? v ?? s : undefined, + ( + s: any, + v: any, + _k: string | number | symbol, + _obj: any, + _src: any, + stack: { size: number }, + ) => (stack.size > 0 || Array.isArray(v) ? v ?? s : undefined), ); } diff --git a/src/engines/Cesium/utils/polygon.ts b/src/engines/Cesium/utils/polygon.ts index fb72ffb..0dd6dbc 100644 --- a/src/engines/Cesium/utils/polygon.ts +++ b/src/engines/Cesium/utils/polygon.ts @@ -21,8 +21,8 @@ export function convertGeometryToPositionsArray( geometry.type === "LineString" ? coordinatesToPositionsArray([geometry.coordinates]) : geometry.type === "Polygon" - ? coordinatesToPositionsArray(geometry.coordinates) - : geometry.coordinates.flatMap(coordinates => coordinatesToPositionsArray(coordinates)) + ? coordinatesToPositionsArray(geometry.coordinates) + : geometry.coordinates.flatMap(coordinates => coordinatesToPositionsArray(coordinates)) ).filter(({ length }) => length > 0); } diff --git a/src/mantle/atoms/compute.ts b/src/mantle/atoms/compute.ts index 3134501..963239a 100644 --- a/src/mantle/atoms/compute.ts +++ b/src/mantle/atoms/compute.ts @@ -178,8 +178,8 @@ export function computeAtom(cache?: typeof globalDataFeaturesCache) { ...("properties" in value ? { properties: value.properties } : l && "properties" in l - ? { properties: l.properties } - : {}), + ? { properties: l.properties } + : {}), } : undefined, ); From 1226dad50e07495b4688977c7470f452dff0029b Mon Sep 17 00:00:00 2001 From: soy Date: Wed, 15 May 2024 09:47:15 +0900 Subject: [PATCH 4/5] chore: update eslint configurations --- .eslintrc.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index f8c5f4e..075caff 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -1,2 +1,21 @@ extends: - - reearth \ No newline at end of file + - reearth +rules: + no-restricted-imports: + - error + - paths: + - name: lodash + message: Use lodash-es instead. + import/order: + - warn + - pathGroups: + - pattern: "@reearth/**" + group: external + position: after + pathGroupsExcludedImportTypes: ["builtin"] + newlines-between: always + alphabetize: + order: asc + caseInsensitive: true + "@typescript-eslint/no-explicit-any": + - warn \ No newline at end of file From a2f5ccf24b07b84fd587cfa31d06d3812320489e Mon Sep 17 00:00:00 2001 From: soy Date: Thu, 16 May 2024 22:50:05 +0900 Subject: [PATCH 5/5] fix: remove lint option `--max-warnings 0` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6fd4f01..66c366d 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "scripts": { "dev": "vite", "build": "tsc && vite build", - "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives", "preview": "vite preview", "test": "vitest", "storybook": "storybook dev -p 6007",