css is now string | CSSStyleSheet. A sheet is adopted as-is: into its own
shadow root, an enclosing shadow root, or document.adoptedStyleSheets for
light DOM at the document level. Strings behave as before.
The examples import their styles with `with { type: 'css' }` and their
static templates with `with { type: 'text' }`. Safari doesn't support those
yet, so vite.config.ts rewrites them into modules Vite builds: a constructed
CSSStyleSheet, or the file's text. npm run examples now just runs vite,
with root set in the config.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
import { defineConfig } from 'oxlint';
|
|
|
|
export default defineConfig({
|
|
plugins: ['typescript', 'unicorn', 'oxc', 'import', 'promise'],
|
|
categories: {
|
|
correctness: 'error',
|
|
suspicious: 'error',
|
|
pedantic: 'error',
|
|
perf: 'error',
|
|
restriction: 'error',
|
|
},
|
|
rules: {
|
|
// Guards for code compiled down to pre-ES2018/2020; this targets ESNext.
|
|
'oxc/no-optional-chaining': 'off',
|
|
'oxc/no-rest-spread-properties': 'off',
|
|
'oxc/no-async-await': 'off',
|
|
// `void promise;` is how `no-floating-promises` says to ignore one on purpose.
|
|
'eslint/no-void': ['error', { allowAsStatement: true }],
|
|
// `undefined` is a real prop value (`userId: number | undefined`).
|
|
'eslint/no-undefined': 'off',
|
|
// Members are public by default and private via `#`; `public` is noise.
|
|
'typescript/explicit-member-accessibility': 'off',
|
|
// DOM types can't be deeply readonly, so every `Element` parameter fails.
|
|
'typescript/prefer-readonly-parameter-types': 'off',
|
|
// `function foo()` over `const foo = () => ...`. Inline callbacks
|
|
// (`.map((x) => ...)`) and arrows that use `this` aren't affected.
|
|
'eslint/func-style': ['error', 'declaration'],
|
|
// The mixin's hooks are deliberately empty methods for subclasses to override.
|
|
'eslint/class-methods-use-this': [
|
|
'error',
|
|
{
|
|
exceptMethods: ['handleEvent', 'onConnect', 'onDisconnect', 'onPropChange'],
|
|
ignoreOverrideMethods: true,
|
|
},
|
|
],
|
|
},
|
|
overrides: [
|
|
{
|
|
files: ['test/**/*.ts'],
|
|
plugins: ['typescript', 'unicorn', 'oxc', 'import', 'promise', 'vitest'],
|
|
rules: {
|
|
// Tests import the source under test from `../src`.
|
|
'import/no-relative-parent-imports': 'off',
|
|
// `describe` callbacks are long, and each test of a class factory
|
|
// needs its own small class.
|
|
'eslint/max-lines-per-function': 'off',
|
|
'eslint/max-classes-per-file': 'off',
|
|
// Test files grow with coverage; splitting them by line count doesn't help.
|
|
'eslint/max-lines': 'off',
|
|
},
|
|
},
|
|
{
|
|
files: ['examples/**/*.ts'],
|
|
rules: {
|
|
// Examples import the library from `../src`, like the tests.
|
|
'import/no-relative-parent-imports': 'off',
|
|
// Importing a component module is how it gets registered.
|
|
'import/no-unassigned-import': 'off',
|
|
// `onPropChange` switches are exhaustive over prop names, which
|
|
// `switch-exhaustiveness-check` enforces; a `default` would hide a missed one.
|
|
'eslint/default-case': 'off',
|
|
},
|
|
},
|
|
{
|
|
// Ambient declaration files are scripts on purpose: no imports or exports.
|
|
files: ['**/*.d.ts'],
|
|
rules: {
|
|
'import/unambiguous': 'off',
|
|
},
|
|
},
|
|
],
|
|
env: {
|
|
builtin: true,
|
|
browser: true,
|
|
},
|
|
ignorePatterns: ['dist/'],
|
|
});
|