Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ci settings #8

Merged
merged 5 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
extends:
- reearth
- 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
9 changes: 9 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bug:
- "bug"
- "fix"
enhancement:
- "enhancement"
- "feature"
documentation:
- "docs"
- "documentation"
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/pr_title.yml
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 4 additions & 5 deletions example/src/main.tsx
Original file line number Diff line number Diff line change
@@ -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(
<App />,
)
import App from "./App.tsx";

ReactDOM.createRoot(document.getElementById("root")!).render(<App />);
2 changes: 1 addition & 1 deletion example/vite.config.ts
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 8 additions & 2 deletions src/Map/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down
1 change: 0 additions & 1 deletion src/engines/Cesium/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ declare module "@cesium/engine" {
// (...args: Parameter<Listener>[]).
// This cannot be fixed by augmentation but by overloading.
export interface Event<Listener extends (...args: any[]) => void = (...args: any[]) => void> {
// eslint-disable-next-line @typescript-eslint/method-signature-style
raiseEvent(...arguments: Parameters<Listener>): void;
}

Expand Down
4 changes: 2 additions & 2 deletions src/engines/Cesium/utils/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/mantle/atoms/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
2 changes: 1 addition & 1 deletion src/mantle/data/gpx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 0 additions & 2 deletions src/mantle/evaluator/simple/expression/variableReplacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any[]> = {};
const varExpRegex = /^\$./;
while (i >= 0) {
Expand Down
5 changes: 0 additions & 5 deletions src/mantle/evaluator/simple/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]) => {
Expand All @@ -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
Expand All @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/mantle/evaluator/simple/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/test/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Loading