Skip to content

Commit

Permalink
Improve TS2.0 template (#794)
Browse files Browse the repository at this point in the history
* fix ts2.0 template so it doesn;t break on lint task

* update dev dependencies on ts2.0 beta template

* fix frozen lockfile

* fix mrl

* fix lint

* add lint:fix

* remove unused check
  • Loading branch information
ewitkon authored Oct 4, 2024
1 parent 9af346e commit f99c04d
Show file tree
Hide file tree
Showing 12 changed files with 559 additions and 168 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-pigs-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/create-app.template.react.beta": patch
---

fix ts2.0 template so it doesn't break on lint task
5 changes: 5 additions & 0 deletions .changeset/two-geckos-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@osdk/create-app.template.react.beta": patch
---

update dev dependencies
24 changes: 23 additions & 1 deletion examples/example-react-beta/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
overrides: [
{
files: ["*.ts", "*.tsx"],
},
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
plugins: ["react-refresh", "import", "react"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"import/named": "error",
"import/default": "error",
"import/namespace": "error",
"import/no-duplicates": "error",
"react/react-in-jsx-scope": "off", // Disable this rule for React 17+
},
settings: {
react: {
version: "detect", // Automatically detect the React version
},
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
},
};
10 changes: 8 additions & 2 deletions examples/example-react-beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,30 @@
"build": "tsc && vite build",
"dev": "vite",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint --report-unused-disable-directives --max-warnings 0 --fix",
"preview": "vite preview",
"test": "vitest run"
},
"dependencies": {
"@osdk/client": "beta",
"@osdk/client": "latest",
"@osdk/e2e.generated.catchall": "workspace:*",
"@osdk/oauth": "beta",
"@osdk/oauth": "latest",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^6.23.1"
},
"devDependencies": {
"@types/node": "^22.7.4",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.5.4",
Expand Down
7 changes: 4 additions & 3 deletions examples/example-react-beta/src/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import palantirLogo from "/palantir.svg";
import reactLogo from "/react.svg";
import React from "react";
import palantirLogo from "../public/palantir.svg";
import reactLogo from "../public/react.svg";
import css from "./Layout.module.css";

interface LayoutProps {
Expand All @@ -14,10 +14,11 @@ function Layout({ children }: LayoutProps) {
<a
href="https://www.palantir.com/docs/foundry/ontology-sdk/overview/"
target="_blank"
rel="noopener noreferrer"
>
<img src={palantirLogo} className={css.logo} alt="Palantir logo" />
</a>
<a href="https://react.dev" target="_blank">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer">
<img src={reactLogo} className={css.logo} alt="React logo" />
</a>
</div>
Expand Down
3 changes: 2 additions & 1 deletion examples/example-react-beta/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Client, createClient } from "@osdk/client";
import type { Client } from "@osdk/client";
import { createClient } from "@osdk/client";
import { $ontologyRid } from "@osdk/e2e.generated.catchall";
import { createPublicOauthClient } from "@osdk/oauth";

Expand Down
5 changes: 5 additions & 0 deletions packages/create-app.template.react.beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,17 @@
"@osdk/monorepo.api-extractor": "workspace:~",
"@osdk/monorepo.tsconfig": "workspace:~",
"@osdk/monorepo.tsup": "workspace:~",
"@types/node": "^22.7.4",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "^7.16.0",
"@typescript-eslint/parser": "^7.16.0",
"@vitejs/plugin-react": "^4.2.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.5.4",
Expand Down
24 changes: 23 additions & 1 deletion packages/create-app.template.react.beta/templates/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
overrides: [
{
files: ["*.ts", "*.tsx"],
},
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react-hooks/recommended",
"plugin:jsx-a11y/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
plugins: ["react-refresh", "import", "react"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"import/named": "error",
"import/default": "error",
"import/namespace": "error",
"import/no-duplicates": "error",
"react/react-in-jsx-scope": "off", // Disable this rule for React 17+
},
settings: {
react: {
version: "detect", // Automatically detect the React version
},
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint --report-unused-disable-directives --max-warnings 0 --fix",
"test": "vitest run",
"preview": "vite preview"
},
"dependencies": {
"{{osdkPackage}}": "latest",
"@osdk/client": "beta",
"@osdk/oauth": "beta"
"@osdk/client": "latest",
"@osdk/oauth": "latest"
},
"devDependencies": {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import palantirLogo from "/palantir.svg";
import reactLogo from "/react.svg";
import React from "react";
import palantirLogo from "../public/palantir.svg";
import reactLogo from "../public/react.svg";
import css from "./Layout.module.css";

interface LayoutProps {
Expand All @@ -14,10 +14,11 @@ function Layout({ children }: LayoutProps) {
<a
href="https://www.palantir.com/docs/foundry/ontology-sdk/overview/"
target="_blank"
rel="noopener noreferrer"
>
<img src={palantirLogo} className={css.logo} alt="Palantir logo" />
</a>
<a href="https://react.dev" target="_blank">
<a href="https://react.dev" target="_blank" rel="noopener noreferrer">
<img src={reactLogo} className={css.logo} alt="React logo" />
</a>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Client, createClient } from "@osdk/client";
import type { Client } from "@osdk/client";
import { createClient } from "@osdk/client";
import { $ontologyRid } from "{{osdkPackage}}";
import { createPublicOauthClient } from "@osdk/oauth";

Expand Down
Loading

0 comments on commit f99c04d

Please sign in to comment.