Initial commit
This commit is contained in:
68
packages/config/eslint/index.js
Normal file
68
packages/config/eslint/index.js
Normal file
@@ -0,0 +1,68 @@
|
||||
import js from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import { fixupPluginRules } from '@eslint/compat';
|
||||
import reactPlugin from 'eslint-plugin-react';
|
||||
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
||||
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
|
||||
|
||||
/** Base ESLint config for all TS packages (no React). */
|
||||
export const base = tseslint.config(
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/consistent-type-imports': [
|
||||
'error',
|
||||
{ prefer: 'type-imports', fixStyle: 'inline-type-imports' },
|
||||
],
|
||||
'no-console': 'warn',
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
regex: '^(\\.+/[^\'"]*)\\.(js|jsx|ts|tsx)$',
|
||||
message:
|
||||
'Use extensionless imports. Import from "./module" instead of "./module.js".',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
ignores: ['**/dist/**', '**/generated/**', '**/.next/**', '**/node_modules/**'],
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* ESLint config for React/Next.js packages.
|
||||
*
|
||||
* `fixupPluginRules` wraps ESLint 9-era plugins for ESLint 10 compatibility.
|
||||
*/
|
||||
export const react = tseslint.config(...base, {
|
||||
plugins: {
|
||||
react: fixupPluginRules(reactPlugin),
|
||||
'react-hooks': fixupPluginRules(reactHooksPlugin),
|
||||
'jsx-a11y': fixupPluginRules(jsxA11yPlugin),
|
||||
},
|
||||
settings: {
|
||||
react: { version: 'detect' },
|
||||
},
|
||||
rules: {
|
||||
'react/react-in-jsx-scope': 'off',
|
||||
'react/prop-types': 'off',
|
||||
'react-hooks/rules-of-hooks': 'error',
|
||||
'react-hooks/exhaustive-deps': 'warn',
|
||||
'jsx-a11y/alt-text': 'error',
|
||||
'jsx-a11y/aria-props': 'error',
|
||||
'jsx-a11y/aria-role': 'error',
|
||||
'jsx-a11y/interactive-supports-focus': 'warn',
|
||||
'jsx-a11y/label-has-associated-control': 'error',
|
||||
},
|
||||
});
|
||||
|
||||
export default base;
|
||||
40
packages/config/package.json
Normal file
40
packages/config/package.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@dwellops/config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./eslint": "./eslint/index.js",
|
||||
"./prettier": "./prettier/index.js",
|
||||
"./stylelint": "./stylelint/index.js",
|
||||
"./tsconfig/base.json": "./tsconfig/base.json",
|
||||
"./tsconfig/nextjs.json": "./tsconfig/nextjs.json",
|
||||
"./tsconfig/node.json": "./tsconfig/node.json",
|
||||
"./tsconfig/react-library.json": "./tsconfig/react-library.json",
|
||||
"./vitest": "./vitest/index.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/js": "catalog:",
|
||||
"@eslint/compat": "catalog:",
|
||||
"typescript-eslint": "catalog:",
|
||||
"eslint-plugin-react": "catalog:",
|
||||
"eslint-plugin-react-hooks": "catalog:",
|
||||
"eslint-plugin-jsx-a11y": "catalog:",
|
||||
"stylelint-config-standard": "catalog:"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"vitest": ">=4.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"vitest": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "catalog:",
|
||||
"eslint": "catalog:",
|
||||
"prettier": "catalog:",
|
||||
"stylelint": "catalog:",
|
||||
"@types/node": "catalog:"
|
||||
}
|
||||
}
|
||||
19
packages/config/prettier/index.js
Normal file
19
packages/config/prettier/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/** @type {import('prettier').Config} */
|
||||
const config = {
|
||||
tabWidth: 4,
|
||||
singleQuote: true,
|
||||
trailingComma: 'all',
|
||||
semi: true,
|
||||
printWidth: 100,
|
||||
bracketSpacing: true,
|
||||
arrowParens: 'always',
|
||||
endOfLine: 'lf',
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.json', '*.yaml', '*.yml'],
|
||||
options: { tabWidth: 2 },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
31
packages/config/stylelint/index.js
Normal file
31
packages/config/stylelint/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/** @type {import('stylelint').Config} */
|
||||
const config = {
|
||||
extends: ['stylelint-config-standard'],
|
||||
rules: {
|
||||
// CSS custom properties (design tokens) — allowed anywhere
|
||||
'custom-property-pattern': null,
|
||||
// CSS Modules compose pattern
|
||||
'value-keyword-case': ['lower', { camelCaseSvgKeywords: true }],
|
||||
// Allow CSS nesting (supported by PostCSS preset-env)
|
||||
'no-descending-specificity': null,
|
||||
},
|
||||
overrides: [
|
||||
{
|
||||
files: ['**/*.module.css'],
|
||||
rules: {
|
||||
// CSS Modules classes are accessed as JS identifiers, so camelCase is idiomatic
|
||||
'selector-class-pattern': [
|
||||
'^[a-z][a-zA-Z0-9]*$',
|
||||
{ message: 'Expected class selector to be camelCase (CSS Modules)' },
|
||||
],
|
||||
// :local() and :global() selectors in CSS Modules
|
||||
'selector-pseudo-class-no-unknown': [
|
||||
true,
|
||||
{ ignorePseudoClasses: ['local', 'global'] },
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default config;
|
||||
20
packages/config/tsconfig/base.json
Normal file
20
packages/config/tsconfig/base.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"skipLibCheck": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
||||
14
packages/config/tsconfig/nextjs.json
Normal file
14
packages/config/tsconfig/nextjs.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["dom", "dom.iterable", "ES2022"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler",
|
||||
"allowJs": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [{ "name": "next" }]
|
||||
}
|
||||
}
|
||||
10
packages/config/tsconfig/node.json
Normal file
10
packages/config/tsconfig/node.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2022"],
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Bundler"
|
||||
}
|
||||
}
|
||||
9
packages/config/tsconfig/react-library.json
Normal file
9
packages/config/tsconfig/react-library.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"extends": "./base.json",
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"lib": ["dom", "dom.iterable", "ES2022"],
|
||||
"jsx": "react-jsx"
|
||||
}
|
||||
}
|
||||
37
packages/config/vitest/index.js
Normal file
37
packages/config/vitest/index.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
/**
|
||||
* Creates a base Vitest config for a workspace package.
|
||||
*
|
||||
* @param {import('vitest/config').UserConfig} [overrides] - Package-specific overrides.
|
||||
* @returns {import('vitest/config').UserConfig}
|
||||
*/
|
||||
export function createVitestConfig(overrides = {}) {
|
||||
return defineConfig({
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['text', 'json', 'html'],
|
||||
thresholds: {
|
||||
lines: 85,
|
||||
functions: 85,
|
||||
branches: 85,
|
||||
statements: 85,
|
||||
},
|
||||
exclude: [
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
'**/generated/**',
|
||||
'**/*.d.ts',
|
||||
'**/*.config.*',
|
||||
'**/index.ts',
|
||||
],
|
||||
},
|
||||
},
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
export default createVitestConfig();
|
||||
Reference in New Issue
Block a user