mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-25 12:52:47 -07:00
fix: eslint configuration
This commit is contained in:
@@ -0,0 +1,103 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"reportUnusedDisableDirectives": true,
|
||||||
|
"ignorePatterns": ["**/build", "**/dist"],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"plugins": ["@typescript-eslint", "import"],
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:@typescript-eslint/stylistic",
|
||||||
|
"plugin:import/recommended",
|
||||||
|
"plugin:import/typescript",
|
||||||
|
"prettier",
|
||||||
|
],
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2020": true,
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"tsconfigRootDir": ".",
|
||||||
|
"project": true,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
},
|
||||||
|
"settings": {
|
||||||
|
"import/parsers": {
|
||||||
|
"@typescript-eslint/parser": [".ts", ".tsx"],
|
||||||
|
},
|
||||||
|
"import/resolver": {
|
||||||
|
"typescript": true,
|
||||||
|
},
|
||||||
|
"react": {
|
||||||
|
"version": "detect",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"@typescript-eslint/array-type": "error",
|
||||||
|
"@typescript-eslint/ban-types": "error",
|
||||||
|
"@typescript-eslint/ban-ts-comment": "error",
|
||||||
|
"@typescript-eslint/consistent-type-definitions": "error",
|
||||||
|
"@typescript-eslint/consistent-type-imports": [
|
||||||
|
"error",
|
||||||
|
{ "prefer": "type-imports" },
|
||||||
|
],
|
||||||
|
"@typescript-eslint/explicit-module-boundary-types": "error",
|
||||||
|
"@typescript-eslint/method-signature-style": ["error", "property"],
|
||||||
|
"@typescript-eslint/naming-convention": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"selector": "typeParameter",
|
||||||
|
"format": ["PascalCase"],
|
||||||
|
"leadingUnderscore": "forbid",
|
||||||
|
"trailingUnderscore": "forbid",
|
||||||
|
"custom": {
|
||||||
|
"regex": "^(T|T[A-Z][A-Za-z]+)$",
|
||||||
|
"match": true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"@typescript-eslint/no-empty-function": "error",
|
||||||
|
"@typescript-eslint/no-empty-interface": "error",
|
||||||
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-condition": "error",
|
||||||
|
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||||
|
"@typescript-eslint/no-unused-vars": "error",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "error",
|
||||||
|
"@typescript-eslint/no-inferrable-types": [
|
||||||
|
"error",
|
||||||
|
{ "ignoreParameters": true },
|
||||||
|
],
|
||||||
|
"import/default": "error",
|
||||||
|
"import/export": "error",
|
||||||
|
"import/namespace": "error",
|
||||||
|
"import/newline-after-import": "error",
|
||||||
|
"import/no-cycle": "error",
|
||||||
|
"import/no-duplicates": "off",
|
||||||
|
"import/no-named-as-default-member": "error",
|
||||||
|
"import/no-unused-modules": "error",
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"groups": [
|
||||||
|
"builtin",
|
||||||
|
"external",
|
||||||
|
"internal",
|
||||||
|
"parent",
|
||||||
|
"sibling",
|
||||||
|
"index",
|
||||||
|
"object",
|
||||||
|
"type",
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-case-declarations": "error",
|
||||||
|
"no-empty": "error",
|
||||||
|
"no-prototype-builtins": "error",
|
||||||
|
"no-redeclare": "error",
|
||||||
|
"no-shadow": "error",
|
||||||
|
"no-undef": "error",
|
||||||
|
"sort-imports": "error",
|
||||||
|
},
|
||||||
|
}
|
||||||
-108
@@ -1,108 +0,0 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
/** @type {import('eslint').Linter.Config} */
|
|
||||||
const config = {
|
|
||||||
root: true,
|
|
||||||
reportUnusedDisableDirectives: true,
|
|
||||||
ignorePatterns: ['**/build', '**/dist'],
|
|
||||||
parser: '@typescript-eslint/parser',
|
|
||||||
plugins: ['@typescript-eslint', 'import'],
|
|
||||||
extends: [
|
|
||||||
'eslint:recommended',
|
|
||||||
'plugin:@typescript-eslint/recommended',
|
|
||||||
'plugin:@typescript-eslint/stylistic',
|
|
||||||
'plugin:import/recommended',
|
|
||||||
'plugin:import/typescript',
|
|
||||||
'prettier',
|
|
||||||
],
|
|
||||||
env: {
|
|
||||||
browser: true,
|
|
||||||
es2020: true,
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
tsconfigRootDir: __dirname,
|
|
||||||
project: true,
|
|
||||||
sourceType: 'module',
|
|
||||||
ecmaVersion: 2020,
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
'import/parsers': {
|
|
||||||
'@typescript-eslint/parser': ['.ts', '.tsx'],
|
|
||||||
},
|
|
||||||
'import/resolver': {
|
|
||||||
typescript: true,
|
|
||||||
},
|
|
||||||
react: {
|
|
||||||
version: 'detect',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'@typescript-eslint/array-type': 'error',
|
|
||||||
'@typescript-eslint/ban-types': 'error',
|
|
||||||
'@typescript-eslint/ban-ts-comment': 'error',
|
|
||||||
'@typescript-eslint/consistent-type-definitions': 'error',
|
|
||||||
'@typescript-eslint/consistent-type-imports': [
|
|
||||||
'error',
|
|
||||||
{ prefer: 'type-imports' },
|
|
||||||
],
|
|
||||||
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
||||||
'@typescript-eslint/method-signature-style': ['error', 'property'],
|
|
||||||
'@typescript-eslint/naming-convention': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
selector: 'typeParameter',
|
|
||||||
format: ['PascalCase'],
|
|
||||||
leadingUnderscore: 'forbid',
|
|
||||||
trailingUnderscore: 'forbid',
|
|
||||||
custom: {
|
|
||||||
regex: '^(T|T[A-Z][A-Za-z]+)$',
|
|
||||||
match: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@typescript-eslint/no-empty-function': 'error',
|
|
||||||
'@typescript-eslint/no-empty-interface': 'error',
|
|
||||||
'@typescript-eslint/no-explicit-any': 'error',
|
|
||||||
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
||||||
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
||||||
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
|
|
||||||
'@typescript-eslint/no-unused-vars': 'error',
|
|
||||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
|
||||||
'@typescript-eslint/no-inferrable-types': [
|
|
||||||
'error',
|
|
||||||
{ ignoreParameters: true },
|
|
||||||
],
|
|
||||||
'import/default': 'error',
|
|
||||||
'import/export': 'error',
|
|
||||||
'import/namespace': 'error',
|
|
||||||
'import/newline-after-import': 'error',
|
|
||||||
'import/no-cycle': 'error',
|
|
||||||
'import/no-duplicates': 'off',
|
|
||||||
'import/no-named-as-default-member': 'error',
|
|
||||||
'import/no-unused-modules': 'error',
|
|
||||||
'import/order': [
|
|
||||||
'error',
|
|
||||||
{
|
|
||||||
groups: [
|
|
||||||
'builtin',
|
|
||||||
'external',
|
|
||||||
'internal',
|
|
||||||
'parent',
|
|
||||||
'sibling',
|
|
||||||
'index',
|
|
||||||
'object',
|
|
||||||
'type',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'no-case-declarations': 'error',
|
|
||||||
'no-empty': 'error',
|
|
||||||
'no-prototype-builtins': 'error',
|
|
||||||
'no-redeclare': 'error',
|
|
||||||
'no-shadow': 'error',
|
|
||||||
'no-undef': 'error',
|
|
||||||
'sort-imports': 'error',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = config
|
|
||||||
+4
-3
@@ -13,14 +13,15 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.12.7",
|
"@types/node": "^20.12.7",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.20.0",
|
"@typescript-eslint/eslint-plugin": "^7.7.1",
|
||||||
"@typescript-eslint/parser": "^6.20.0",
|
"@typescript-eslint/parser": "^7.7.1",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import": "^2.29.1",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
"eslint-plugin-react-hooks": "^4.6.0",
|
"eslint-plugin-react-hooks": "^4.6.0",
|
||||||
"prettier": "^3.2.4"
|
"prettier": "^3.2.4",
|
||||||
|
"typescript": "^5.4.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"lint": "eslint --ext .ts,.tsx ./src -c ../../eslintrc.cjs",
|
"lint": "eslint --ext .ts,.tsx ./src -c ../../.eslintrc",
|
||||||
"format": "prettier --ignore-unknown '**/*'",
|
"format": "prettier --ignore-unknown '**/*'",
|
||||||
"types": "tsc --noEmit"
|
"types": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
export const makeCompile = () => {
|
export const makeCompile = (): void => {
|
||||||
console.log('compiling [compile fn]')
|
console.log('compiling [compile fn]')
|
||||||
}
|
}
|
||||||
|
|
||||||
export const splitFile = async ({}) => {
|
interface SplitFileFnArgs {
|
||||||
console.log('Split file [splitFile fn]')
|
code: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const splitFile = async ({ code }: SplitFileFnArgs): Promise<void> => {
|
||||||
|
console.log('Split file [splitFile fn]', code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import { normalize } from 'path'
|
|
||||||
import { fileURLToPath, pathToFileURL } from 'url'
|
import { fileURLToPath, pathToFileURL } from 'url'
|
||||||
import type { Plugin } from 'vite'
|
|
||||||
|
import { normalize } from 'path'
|
||||||
|
// eslint-disable-next-line sort-imports
|
||||||
import { makeCompile, splitFile } from './compiler'
|
import { makeCompile, splitFile } from './compiler'
|
||||||
|
import type { Plugin } from 'vite'
|
||||||
|
|
||||||
const SPLIT_PREFIX = 'sp-'
|
const SPLIT_PREFIX = 'sp-'
|
||||||
const ROUTES_DIRECTORY_PATH = 'src/routes'
|
const ROUTES_DIRECTORY_PATH = 'src/routes'
|
||||||
@@ -10,7 +12,7 @@ const DEBUG = true
|
|||||||
let lock = false
|
let lock = false
|
||||||
|
|
||||||
export function RouterGenerator(): Plugin {
|
export function RouterGenerator(): Plugin {
|
||||||
const _generate = async () => {
|
const _generate = async (): Promise<void> => {
|
||||||
if (lock) return
|
if (lock) return
|
||||||
lock = true
|
lock = true
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ export function RouterGenerator(): Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleFile = async (file: string) => {
|
const handleFile = async (file: string): Promise<void> => {
|
||||||
const filePath = normalize(file)
|
const filePath = normalize(file)
|
||||||
|
|
||||||
if (filePath.startsWith(ROUTES_DIRECTORY_PATH)) {
|
if (filePath.startsWith(ROUTES_DIRECTORY_PATH)) {
|
||||||
@@ -35,7 +37,10 @@ export function RouterGenerator(): Plugin {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
name: 'vite-plugin-fs-router-generator',
|
name: 'vite-plugin-fs-router-generator',
|
||||||
watchChange: async (file: string, context: { event: string }) => {
|
watchChange: async (
|
||||||
|
file: string,
|
||||||
|
context: { event: string },
|
||||||
|
): Promise<void> => {
|
||||||
if (['create', 'update', 'delete'].includes(context.event)) {
|
if (['create', 'update', 'delete'].includes(context.event)) {
|
||||||
await handleFile(file)
|
await handleFile(file)
|
||||||
}
|
}
|
||||||
@@ -47,13 +52,13 @@ export function RouterCodeSplitter(): Plugin {
|
|||||||
return {
|
return {
|
||||||
name: 'vite-plugin-fs-router-code-splitter',
|
name: 'vite-plugin-fs-router-code-splitter',
|
||||||
enforce: 'pre',
|
enforce: 'pre',
|
||||||
resolveId(source) {
|
resolveId(source): string {
|
||||||
if (source.startsWith(SPLIT_PREFIX + ':')) {
|
if (source.startsWith(SPLIT_PREFIX + ':')) {
|
||||||
return source.replace(SPLIT_PREFIX + ':', '')
|
return source.replace(SPLIT_PREFIX + ':', '')
|
||||||
}
|
}
|
||||||
return
|
return ''
|
||||||
},
|
},
|
||||||
async transform(code, id) {
|
async transform(code, id): Promise<void> {
|
||||||
const url = pathToFileURL(id)
|
const url = pathToFileURL(id)
|
||||||
url.searchParams.delete('v')
|
url.searchParams.delete('v')
|
||||||
id = fileURLToPath(url).replace(/\\/g, '/')
|
id = fileURLToPath(url).replace(/\\/g, '/')
|
||||||
@@ -91,6 +96,6 @@ export function RouterCodeSplitter(): Plugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ViteFsRouter(): Array<Plugin> {
|
export function ViteFsRouter(): Plugin[] {
|
||||||
return [RouterGenerator(), RouterCodeSplitter()]
|
return [RouterGenerator(), RouterCodeSplitter()]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user