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

Move eslint and prettier to root of monorepo #2019

Merged
merged 12 commits into from
Sep 2, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 0 additions & 18 deletions .eslintrc.cjs

This file was deleted.

17 changes: 17 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Ignore dist builds
packages/*/dist
packages/*/build

# Ignore schemas
packages/common/validation/schemas

# Ignore node_modules
node_modules
packages/*/node_modules

# Ignore image assets
*.png

# Ignore test assets
*.tar.xz
*.sh
5 changes: 3 additions & 2 deletions packages/admin-ui/.prettierrc → .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"printWidth": 80,
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
Expand All @@ -9,5 +9,6 @@
"trailingComma": "none",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "avoid"
"arrowParens": "always",
"endOfLine": "auto"
}
49 changes: 49 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { FlatCompat } from "@eslint/eslintrc";
import { parse } from "@typescript-eslint/parser";
import path from "path";
import { fileURLToPath } from "url";
import js from "@eslint/js";

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
resolvePluginsRelativeTo: __dirname, // optional
recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended"
allConfig: js.configs.all // optional unless using "eslint:all"
});

export default [
{
// Basic settings
languageOptions: {
parser: parse,
parserOptions: {
project: "./tsconfig.json", // Adjust path if necessary
tsconfigRootDir: __dirname,
sourceType: "module"
}
},
ignores: [
"packages/common/validation/schemas",
"node_modules",
"packages/*/dist",
"packages/*/node_modules",
"packages/*/build"
]
},

// Optionally, add compatibility with old configs
...compat.config({
plugins: ["@typescript-eslint", "prettier"],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
rules: {
"prettier/prettier": "error",
"no-unused-expressions": "off", // Disable standard no-unused-expressions rule
"@typescript-eslint/no-unused-expressions": "off", // Disable TypeScript-specific rule
"@typescript-eslint/no-unused-vars": ["error", { varsIgnorePattern: "^_", argsIgnorePattern: "^_" }]
}
})
];
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@dappnode/dappnode",
"name": "root",
"type": "module",
"version": "1.0.0",
"private": true,
Expand All @@ -16,26 +16,35 @@
"test": "yarn workspaces foreach --all -pt run test",
"test:int": "yarn workspaces foreach --all -pt run test:int",
"dev": "yarn workspaces foreach --all -pi -j unlimited run dev",
"lint": "yarn workspaces foreach --all -pt run lint",
"lint": "eslint 'packages/**/src/**/*.{js,ts,tsx}' 'packages/**/test/**/*.{js,ts,tsx}' --ignore-pattern 'packages/common/src/validation/schemas/**/*.{js,ts,tsx}'",
"lint:fix": "eslint 'packages/**/src/**/*.{js,ts,tsx}' 'packages/**/test/**/*.{js,ts,tsx}' --fix --ignore-pattern 'packages/common/src/validation/schemas/**/*.{js,ts,tsx}'",
"format": "prettier --write 'packages/**/src/**/*.{js,ts,tsx,json,md}' 'packages/**/test/**/*.{js,ts,tsx,json,md}'",
"mock-standalone:build": "yarn workspace @dappnode/admin-ui run mock-standalone:build",
"mock-standalone": "yarn workspace @dappnode/admin-ui run mock-standalone",
"generate": "yarn workspace @dappnode/common run generate"
},
"devDependencies": {
"@eslint/eslintrc": "^3.1.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^22.2.0",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"chai": "^4.3.10",
"depcheck": "^1.4.7",
"eslint": "^8.44.0",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.1.0",
"mocha": "^10.2.0",
"nodemon": "^3.0.2",
"prettier": "^3.3.3",
"rimraf": "^3.0.2",
"tsx": "^4.17.0",
"typescript": "^5.5.4"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
8 changes: 0 additions & 8 deletions packages/admin-ui/.eslintignore

This file was deleted.

6 changes: 0 additions & 6 deletions packages/admin-ui/.eslintrc.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions packages/admin-ui/.prettierignore

This file was deleted.

2 changes: 0 additions & 2 deletions packages/admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
"start": "VITE_APP_API_TEST=true vite",
"build": "tsc -b && vite build",
"analyze": "npx source-map-explorer build/static/js/main.*",
"lint": "eslint --ext ts,tsx,js,jsx --fix src",
"prettier": "prettier --write 'src/**/*.*'",
"mock": "VITE_APP_API_URL=http://localhost:5000 yarn start",
"server-mock": "PORT=5000 nodemon server-mock/index.ts",
"server-mock:check-types": "tsc --noEmit --project tsconfig.server-mock.json",
Expand Down
31 changes: 13 additions & 18 deletions packages/admin-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const useLocalStorage = <T extends string>(
// Assert that either the item or initialValue is of type T
return (item as T) || initialValue;
} catch (error) {
console.error(error);
return initialValue;
}
});
Expand All @@ -55,12 +56,14 @@ function MainApp({ username }: { username: string }) {

const [screenWidth, setScreenWidth] = useState(window.innerWidth);
const [theme, setTheme] = useLocalStorage<Theme>("theme", "light");
const [stakersModuleStatus, setStakersModuleStatus] = useLocalStorage<
UiModuleStatus
>("stakersModuleStatus", "enabled");
const [rollupsModuleStatus, setRollupsModuleStatus] = useLocalStorage<
UiModuleStatus
>("rollupsModuleStatus", "disabled");
const [stakersModuleStatus, setStakersModuleStatus] = useLocalStorage<UiModuleStatus>(
"stakersModuleStatus",
"enabled"
);
const [rollupsModuleStatus, setRollupsModuleStatus] = useLocalStorage<UiModuleStatus>(
"rollupsModuleStatus",
"disabled"
);

useEffect(() => {
const handleResize = () => setScreenWidth(window.innerWidth);
Expand All @@ -78,16 +81,11 @@ function MainApp({ username }: { username: string }) {
theme,
stakersModuleStatus,
rollupsModuleStatus,
toggleTheme: () =>
setTheme((curr: Theme) => (curr === "light" ? "dark" : "light")),
toggleTheme: () => setTheme((curr: Theme) => (curr === "light" ? "dark" : "light")),
toggleStakersModuleStatus: () =>
setStakersModuleStatus((curr: UiModuleStatus) =>
curr === "enabled" ? "disabled" : "enabled"
),
setStakersModuleStatus((curr: UiModuleStatus) => (curr === "enabled" ? "disabled" : "enabled")),
toggleRollupsModuleStatus: () =>
setRollupsModuleStatus((curr: UiModuleStatus) =>
curr === "enabled" ? "disabled" : "enabled"
)
setRollupsModuleStatus((curr: UiModuleStatus) => (curr === "enabled" ? "disabled" : "enabled"))
};

return (
Expand Down Expand Up @@ -161,10 +159,7 @@ export default function App() {

// Start API and Socket.io once user has logged in
useEffect(() => {
if (isLoggedIn)
startApi(onFetchLoginStatus).catch(e =>
console.error("Error on startApi", e)
);
if (isLoggedIn) startApi(onFetchLoginStatus).catch((e) => console.error("Error on startApi", e));
}, [isLoggedIn, onFetchLoginStatus]);

// Keep retrying if there is a loggin error, probably due a network error
Expand Down
11 changes: 3 additions & 8 deletions packages/admin-ui/src/__mock-backend__/autoUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { AutoUpdateDataView, Routes } from "@dappnode/types";
import { pause } from "./utils/pause";

export const autoUpdate: Pick<
Routes,
"autoUpdateDataGet" | "autoUpdateSettingsEdit"
> = {
export const autoUpdate: Pick<Routes, "autoUpdateDataGet" | "autoUpdateSettingsEdit"> = {
autoUpdateDataGet: async () => autoUpdateData,
autoUpdateSettingsEdit: async ({ id, enabled }) => {
await pause(500);
if (autoUpdateData.settings[id])
autoUpdateData.settings[id].enabled = enabled;
if (autoUpdateData.settings[id]) autoUpdateData.settings[id].enabled = enabled;

for (const dnp of autoUpdateData.dnpsToShow) {
if (dnp.id === id) dnp.enabled = enabled;
Expand Down Expand Up @@ -79,8 +75,7 @@ const autoUpdateData: AutoUpdateDataView = {
enabled: true,
feedback: {
inQueue: true,
errorMessage:
"More lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
errorMessage: "More lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum"
}
}
]
Expand Down
3 changes: 1 addition & 2 deletions packages/admin-ui/src/__mock-backend__/data/directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ function getDirectoryDnp(dnp: MockDnp, index: number): DirectoryItemOk {
index,
status: "ok",
name: dnp.manifest.name,
description:
dnp.manifest.shortDescription || dnp.manifest.description || "",
description: dnp.manifest.shortDescription || dnp.manifest.description || "",
avatarUrl: dnp.avatar || "",
isFeatured: false,
isInstalled: Boolean(dnp.installedData),
Expand Down
36 changes: 9 additions & 27 deletions packages/admin-ui/src/__mock-backend__/data/dnpInstalled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ import { mockDnps } from "./dnps";
function getInstalledDnp(dnp: MockDnp): InstalledPackageDetailData {
const dnpName = dnp.manifest.name;

function getContainer(
serviceName: string,
container: Partial<PackageContainer>
): PackageContainer {
function getContainer(serviceName: string, container: Partial<PackageContainer>): PackageContainer {
return {
...sampleContainer,
containerId: `0000000000000${dnpName}`,
Expand Down Expand Up @@ -48,17 +45,13 @@ function getInstalledDnp(dnp: MockDnp): InstalledPackageDetailData {
userSettings: { environment: dnp.userSettings?.environment },
setupWizard: dnp.setupWizard && {
...dnp.setupWizard,
fields: dnp.setupWizard.fields.filter(
f => f.target?.type === "environment"
)
fields: dnp.setupWizard.fields.filter((f) => f.target?.type === "environment")
},
containers: dnp.installedContainers
? Object.entries(dnp.installedContainers).map(
([serviceName, container]) => ({
...getContainer(serviceName, container),
...container
})
)
? Object.entries(dnp.installedContainers).map(([serviceName, container]) => ({
...getContainer(serviceName, container),
...container
}))
: [getContainer(dnpName, {})],

...dnp.installedData
Expand All @@ -75,21 +68,10 @@ const getContainerName = ({
isCore: boolean;
}): string =>
// Note: _PREFIX variables already end with the character "-"
[
isCore ? "DAppNodeCore-" : "DAppNodePackage-",
getContainerDomain({ dnpName, serviceName })
].join("");
[isCore ? "DAppNodeCore-" : "DAppNodePackage-", getContainerDomain({ dnpName, serviceName })].join("");

const getContainerDomain = ({
dnpName,
serviceName
}: {
serviceName?: string;
dnpName: string;
}): string => {
return !serviceName || serviceName === dnpName
? dnpName
: `${serviceName}.${dnpName}`;
const getContainerDomain = ({ dnpName, serviceName }: { serviceName?: string; dnpName: string }): string => {
return !serviceName || serviceName === dnpName ? dnpName : `${serviceName}.${dnpName}`;
};

const getImageTag = ({
Expand Down
3 changes: 1 addition & 2 deletions packages/admin-ui/src/__mock-backend__/data/dnpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ function getRequestDnp(dnp: MockDnp): RequestedDnp {
const dnpName = dep.manifest.name;
if (dep.userSettings) settings[dnpName] = dep.userSettings;
if (dep.setupWizard) setupWizard[dnpName] = dep.setupWizard;
if (dep.specialPermissions)
specialPermissions[dnpName] = dep.specialPermissions;
if (dep.specialPermissions) specialPermissions[dnpName] = dep.specialPermissions;
compatibleDnps[dnpName] = {
from: dep.installedData?.version,
to: dep.manifest.version
Expand Down
6 changes: 2 additions & 4 deletions packages/admin-ui/src/__mock-backend__/data/dnps/bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export const bitcoin: MockDnp = {
featuredBackground: "linear-gradient(to right, #4b3317, #cb6e00)",
featuredColor: "white"
},
author:
"DAppNode Association <[email protected]> (https://github.com/dappnode)",
author: "DAppNode Association <[email protected]> (https://github.com/dappnode)",
contributors: [
"Abel Boldú (@vdo)",
"Eduardo Antuña <[email protected]> (https://github.com/eduadiez)",
Expand All @@ -29,8 +28,7 @@ export const bitcoin: MockDnp = {
onRemove: "Make sure you have change the endpoint in your bitcoin miner"
},
keywords: ["bitcoin", "btc"],
// @ts-ignore
homepage: {
links: {
homepage: "https://github.com/dappnode/DAppNodePackage-bitcoin#readme"
},
repository: {
Expand Down
9 changes: 3 additions & 6 deletions packages/admin-ui/src/__mock-backend__/data/dnps/geth.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import { MockDnp } from "./types";

export const geth: MockDnp = {
avatar:
"https://github.com/dappnode/DAppNodePackage-geth/blob/master/geth-avatar.png",
avatar: "https://github.com/dappnode/DAppNodePackage-geth/blob/master/geth-avatar.png",

manifest: {
name: "geth.dnp.dappnode.eth",
version: "0.1.17",
upstreamVersion: "v1.10.21",
upstreamRepo: "ethereum/go-ethereum",
upstreamArg: "UPSTREAM_VERSION",
shortDescription:
"Geth is the official Go implementation of the Ethereum protocol.",
shortDescription: "Geth is the official Go implementation of the Ethereum protocol.",
description:
"Ethereum is a global, open-source platform for decentralized applications where you can write code that controls digital value, runs exactly as programmed, and is accessible anywhere in the world.",
type: "service",
architectures: ["linux/amd64", "linux/arm64"],
chain: "ethereum",
dockerTimeout: "20min",
author:
"DAppNode Association <[email protected]> (https://github.com/dappnode)",
author: "DAppNode Association <[email protected]> (https://github.com/dappnode)",
contributors: [
"Mariano Conti (nanexcool) (hhttps://github.com/nanexcool)",
"Eduardo Antuña <[email protected]> (https://github.com/eduadiez)",
Expand Down
Loading
Loading