You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
3.4 KiB
121 lines
3.4 KiB
import prettier from 'eslint-config-prettier';
|
|
import path from 'node:path';
|
|
import js from '@eslint/js';
|
|
import svelte from 'eslint-plugin-svelte';
|
|
import { defineConfig, includeIgnoreFile } from 'eslint/config';
|
|
import globals from 'globals';
|
|
import ts from 'typescript-eslint';
|
|
|
|
const gitignorePath = path.resolve(import.meta.dirname, '.gitignore');
|
|
|
|
export default defineConfig(
|
|
includeIgnoreFile(gitignorePath),
|
|
js.configs.recommended,
|
|
ts.configs.recommended,
|
|
svelte.configs.recommended,
|
|
prettier,
|
|
svelte.configs.prettier,
|
|
{
|
|
languageOptions: { globals: { ...globals.browser, ...globals.node } },
|
|
rules: {
|
|
// typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
|
|
// see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors
|
|
'no-undef': 'off'
|
|
}
|
|
},
|
|
{
|
|
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
projectService: true,
|
|
extraFileExtensions: ['.svelte'],
|
|
parser: ts.parser
|
|
}
|
|
}
|
|
},
|
|
{
|
|
// Override or add rule settings here, such as:
|
|
// 'svelte/button-has-type': 'error'
|
|
rules: {}
|
|
},
|
|
// --- Package-boundary enforcement (see docs/ARCHITECTURE.md) ---
|
|
{
|
|
// App/project code may only reach core's server-only entries through
|
|
// $lib/server/webavatar-core.ts; server.js and vite.config.ts are the
|
|
// two root-only composition roots allowed to import the package directly.
|
|
files: ['apps/template/**/*.{ts,js,svelte}'],
|
|
ignores: [
|
|
'apps/template/src/lib/server/**',
|
|
'apps/template/server.js',
|
|
'apps/template/vite.config.ts'
|
|
],
|
|
rules: {
|
|
'@typescript-eslint/no-restricted-imports': [
|
|
'error',
|
|
{
|
|
paths: [
|
|
{
|
|
name: '@webavatar/webavatar-core/server',
|
|
message: 'Server-only — import through $lib/server/webavatar-core.js instead.'
|
|
},
|
|
{
|
|
name: '@webavatar/webavatar-core/vite',
|
|
message: 'Server-only — only server.js and vite.config.ts may import this directly.'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
// humanoid may depend on core's public contracts only as types — never
|
|
// on core's runtime values, and never on core's internal file layout.
|
|
files: ['packages/humanoid/src/**/*.ts'],
|
|
rules: {
|
|
'@typescript-eslint/no-restricted-imports': [
|
|
'error',
|
|
{
|
|
paths: [
|
|
{
|
|
name: '@webavatar/webavatar-core',
|
|
allowTypeImports: true,
|
|
message:
|
|
'humanoid may only import core contracts as types (`import type`) — no runtime values.'
|
|
}
|
|
],
|
|
patterns: [
|
|
{
|
|
group: ['**/core/**', '@webavatar/webavatar-core/*', '**/project/**', '**/apps/**'],
|
|
message: 'humanoid must not import core internals, app code, or project code.'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
// Core never imports humanoid, app, or project code, in either direction.
|
|
files: ['packages/core/src/**/*.ts'],
|
|
rules: {
|
|
'@typescript-eslint/no-restricted-imports': [
|
|
'error',
|
|
{
|
|
paths: [
|
|
{ name: '@webavatar/webavatar-humanoid', message: 'core must not import humanoid.' }
|
|
],
|
|
patterns: [
|
|
{
|
|
group: [
|
|
'**/humanoid/**',
|
|
'@webavatar/webavatar-humanoid/*',
|
|
'**/project/**',
|
|
'**/apps/**'
|
|
],
|
|
message: 'core must not import humanoid, app, or project code.'
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|
|
);
|
|
|