Replace entire codebase with homarr-labs/homarr
This commit is contained in:
95
tooling/eslint/base.js
Normal file
95
tooling/eslint/base.js
Normal file
@@ -0,0 +1,95 @@
|
||||
/// <reference types="./types.d.ts" />
|
||||
|
||||
import eslint from "@eslint/js";
|
||||
import importPlugin from "eslint-plugin-import";
|
||||
import tseslint from "typescript-eslint";
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
// Globally ignored files
|
||||
ignores: ["**/*.config.js", "**/*.cjs", "**/lang/*.d.json.ts"],
|
||||
},
|
||||
{
|
||||
files: ["**/*.js", "**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
},
|
||||
extends: [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_" }],
|
||||
"@typescript-eslint/consistent-type-imports": [
|
||||
"warn",
|
||||
{ prefer: "type-imports", fixStyle: "separate-type-imports" },
|
||||
],
|
||||
"@typescript-eslint/no-misused-promises": [2, { checksVoidReturn: { attributes: false } }],
|
||||
"@typescript-eslint/no-unnecessary-condition": [
|
||||
"error",
|
||||
{
|
||||
allowConstantLoopConditions: true,
|
||||
},
|
||||
],
|
||||
"@typescript-eslint/no-non-null-assertion": "error",
|
||||
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
||||
"id-length": [
|
||||
"warn",
|
||||
{
|
||||
min: 3,
|
||||
exceptions: ["_", "i", "z", "t", "id", "db", "fs"], // _ for unused variables, i for index, z for zod, t for translation
|
||||
properties: "never", // This allows for example the use of <Grid.Col span={{ sm: 12, md: 6 }}> as sm and md would be too short
|
||||
},
|
||||
],
|
||||
"no-restricted-syntax": [
|
||||
"error",
|
||||
{
|
||||
selector: "FunctionDeclaration[async=false][id.name=/Async$/]",
|
||||
message: "Function ending in 'Async' must be declared async",
|
||||
},
|
||||
{
|
||||
selector:
|
||||
"FunctionDeclaration[async=true][id.name=/^[a-z].*$/][id.name=/ ^(?!generateMetadata$)[a-z].*$/][id.name!=/Async$/]",
|
||||
message: "Async function name must end in 'Async' (function declaration)",
|
||||
},
|
||||
{
|
||||
selector: "MethodDefinition[value.async=false][key.name=/Async$/]",
|
||||
message: "Method ending in 'Async' must be declared async",
|
||||
},
|
||||
{
|
||||
selector: "MethodDefinition[value.async=true][key.name!=/Async$/]",
|
||||
message: "Async method name must end in 'Async'",
|
||||
},
|
||||
{
|
||||
selector: "Property[value.type=/FunctionExpression$/][value.async=false][key.name=/Async$/]",
|
||||
message: "Function ending in 'Async' must be declared async",
|
||||
},
|
||||
{
|
||||
selector:
|
||||
"Property[value.type=/FunctionExpression$/][value.async=true][key.name!=/^on(Success|Settled)$/][key.name!=/Async$/]",
|
||||
message: "Async function name must end in 'Async' (property)",
|
||||
},
|
||||
{
|
||||
selector: "VariableDeclarator[init.type=/FunctionExpression$/][init.async=false][id.name=/Async$/]",
|
||||
message: "Function ending in 'Async' must be declared async",
|
||||
},
|
||||
{
|
||||
selector:
|
||||
"VariableDeclarator[init.type=/FunctionExpression$/][init.async=true][id.name=/^[a-z].*$/][id.name!=/Async$/]",
|
||||
message: "Async function name must end in 'Async' (variable declarator)",
|
||||
},
|
||||
{
|
||||
// \\u002F is the unicode escape for / and is used because of https://github.com/estools/esquery/issues/68
|
||||
selector: "Literal[value=/^https:\\u002F\\u002Fhomarr\\.dev\\u002F.*$/]",
|
||||
message: "Links to 'https://homarr.dev/' should be used with createDocumentationLink method",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
linterOptions: { reportUnusedDisableDirectives: true },
|
||||
languageOptions: { parserOptions: { project: true } },
|
||||
},
|
||||
);
|
||||
4
tooling/eslint/eslint.config.js
Normal file
4
tooling/eslint/eslint.config.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import baseConfig from "@homarr/eslint-config/base";
|
||||
|
||||
/** @type {import('typescript-eslint').Config} */
|
||||
export default [...baseConfig];
|
||||
17
tooling/eslint/nextjs.js
Normal file
17
tooling/eslint/nextjs.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import nextPlugin from "@next/eslint-plugin-next";
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ["**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
"@next/next": nextPlugin,
|
||||
},
|
||||
rules: {
|
||||
...nextPlugin.configs.recommended.rules,
|
||||
...nextPlugin.configs["core-web-vitals"].rules,
|
||||
// TypeError: context.getAncestors is not a function
|
||||
"@next/next/no-duplicate-head": "off",
|
||||
},
|
||||
},
|
||||
];
|
||||
35
tooling/eslint/package.json
Normal file
35
tooling/eslint/package.json
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@homarr/eslint-config",
|
||||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./base": "./base.js",
|
||||
"./nextjs": "./nextjs.js",
|
||||
"./react": "./react.js"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"lint": "eslint",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"prettier": "@homarr/prettier-config",
|
||||
"dependencies": {
|
||||
"@next/eslint-plugin-next": "16.1.1",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-config-turbo": "^2.7.2",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^6.1.1",
|
||||
"typescript-eslint": "^8.51.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@homarr/prettier-config": "workspace:^0.1.0",
|
||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||
"eslint": "^9.39.2",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
22
tooling/eslint/react.js
vendored
Normal file
22
tooling/eslint/react.js
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import reactPlugin from "eslint-plugin-react";
|
||||
import hooksPlugin from "eslint-plugin-react-hooks";
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ["**/*.ts", "**/*.tsx"],
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
"react-hooks": hooksPlugin,
|
||||
},
|
||||
rules: {
|
||||
...reactPlugin.configs["jsx-runtime"].rules,
|
||||
...hooksPlugin.configs.recommended.rules,
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
React: "writable",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
8
tooling/eslint/tsconfig.json
Normal file
8
tooling/eslint/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@homarr/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
58
tooling/eslint/types.d.ts
vendored
Normal file
58
tooling/eslint/types.d.ts
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Since the ecosystem hasn't fully migrated to ESLint's new FlatConfig system yet,
|
||||
* we "need" to type some of the plugins manually :(
|
||||
*/
|
||||
|
||||
declare module "@eslint/js" {
|
||||
// Why the hell doesn't eslint themselves export their types?
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> };
|
||||
readonly all: { readonly rules: Readonly<Linter.RulesRecord> };
|
||||
};
|
||||
}
|
||||
|
||||
declare module "eslint-plugin-import" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "eslint-plugin-react" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
all: { rules: Linter.RulesRecord };
|
||||
"jsx-runtime": { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "eslint-plugin-react-hooks" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: {
|
||||
rules: {
|
||||
"rules-of-hooks": Linter.RuleEntry;
|
||||
"exhaustive-deps": Linter.RuleEntry;
|
||||
};
|
||||
};
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
|
||||
declare module "@next/eslint-plugin-next" {
|
||||
import type { Linter, Rule } from "eslint";
|
||||
|
||||
export const configs: {
|
||||
recommended: { rules: Linter.RulesRecord };
|
||||
"core-web-vitals": { rules: Linter.RulesRecord };
|
||||
};
|
||||
export const rules: Record<string, Rule.RuleModule>;
|
||||
}
|
||||
3
tooling/github/package.json
Normal file
3
tooling/github/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "@homarr/github"
|
||||
}
|
||||
17
tooling/github/setup/action.yml
Normal file
17
tooling/github/setup/action.yml
Normal file
@@ -0,0 +1,17 @@
|
||||
name: "Setup and install"
|
||||
description: "Common setup steps for Actions"
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- uses: pnpm/action-setup@v4
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
node-version: 24.12.0
|
||||
cache: "pnpm"
|
||||
|
||||
- shell: bash
|
||||
run: pnpm add -g turbo
|
||||
|
||||
- shell: bash
|
||||
run: pnpm install --frozen-lockfile
|
||||
32
tooling/prettier/index.mjs
Normal file
32
tooling/prettier/index.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
/** @typedef {import("prettier").Config} PrettierConfig */
|
||||
/** @typedef {import("@ianvs/prettier-plugin-sort-imports").PluginConfig} SortImportsConfig */
|
||||
|
||||
/** @type { PrettierConfig | SortImportsConfig } */
|
||||
const config = {
|
||||
plugins: ["@ianvs/prettier-plugin-sort-imports", "prettier-plugin-packagejson"],
|
||||
importOrder: [
|
||||
"^(react/(.*)$)|^react$",
|
||||
"^(next/(.*)$)|^(next$)",
|
||||
"<THIRD_PARTY_MODULES>",
|
||||
"",
|
||||
"^@homarr/(.*)$",
|
||||
"",
|
||||
"^~/",
|
||||
"^[../]",
|
||||
"^[./]",
|
||||
],
|
||||
importOrderParserPlugins: ["typescript", "jsx", "decorators-legacy"],
|
||||
printWidth: 120,
|
||||
importOrderTypeScriptVersion: "4.4.0",
|
||||
overrides: [
|
||||
{
|
||||
files: "*.json.hbs",
|
||||
options: {
|
||||
parser: "json",
|
||||
},
|
||||
},
|
||||
],
|
||||
endOfLine: "lf",
|
||||
};
|
||||
|
||||
export default config;
|
||||
21
tooling/prettier/package.json
Normal file
21
tooling/prettier/package.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "@homarr/prettier-config",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"main": "index.mjs",
|
||||
"scripts": {
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"prettier": "@homarr/prettier-config",
|
||||
"dependencies": {
|
||||
"@ianvs/prettier-plugin-sort-imports": "^4.7.0",
|
||||
"prettier": "^3.7.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@homarr/tsconfig": "workspace:^0.1.0",
|
||||
"prettier-plugin-packagejson": "^2.5.20",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
}
|
||||
8
tooling/prettier/tsconfig.json
Normal file
8
tooling/prettier/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "@homarr/tsconfig/base.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
29
tooling/typescript/base.json
Normal file
29
tooling/typescript/base.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2024",
|
||||
"lib": ["dom", "dom.iterable", "ES2024"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"allowArbitraryExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"strictNullChecks": true,
|
||||
"experimentalDecorators": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@homarr/node-unifi": ["${configDir}/../../node_modules/@types/node-unifi"],
|
||||
"*": ["node_modules/*"]
|
||||
}
|
||||
},
|
||||
"exclude": ["node_modules", "build", "dist", ".next"]
|
||||
}
|
||||
8
tooling/typescript/package.json
Normal file
8
tooling/typescript/package.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@homarr/tsconfig",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"files": [
|
||||
"base.json"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user