first commit
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Copyright 2025 LY Corporation
|
||||
*
|
||||
* LY Corporation licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/// <reference types="./types.d.ts" />
|
||||
|
||||
import * as path from 'node:path';
|
||||
import { includeIgnoreFile } from '@eslint/compat';
|
||||
import eslint from '@eslint/js';
|
||||
import importPlugin from 'eslint-plugin-import';
|
||||
import turboPlugin from 'eslint-plugin-turbo';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
import headerPlugin from '@ufb/eslint-plugin-header';
|
||||
|
||||
/**
|
||||
* All packages that leverage t3-env should use this rule
|
||||
*/
|
||||
export const restrictEnvAccess = tseslint.config(
|
||||
{ ignores: ['**/env.ts'] },
|
||||
{
|
||||
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
|
||||
rules: {
|
||||
'no-restricted-properties': [
|
||||
'error',
|
||||
{
|
||||
object: 'process',
|
||||
property: 'env',
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
'no-restricted-imports': [
|
||||
'error',
|
||||
{
|
||||
name: 'process',
|
||||
importNames: ['env'],
|
||||
message:
|
||||
"Use `import { env } from '~/env'` instead to ensure validated types.",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
export default tseslint.config(
|
||||
// Ignore files not tracked by VCS and any config files
|
||||
includeIgnoreFile(path.join(import.meta.dirname, '../../.gitignore')),
|
||||
{ ignores: ['**/*.config.*'] },
|
||||
{
|
||||
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
|
||||
plugins: {
|
||||
import: importPlugin,
|
||||
turbo: turboPlugin,
|
||||
header: headerPlugin,
|
||||
},
|
||||
extends: [
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.recommendedTypeChecked,
|
||||
...tseslint.configs.stylisticTypeChecked,
|
||||
],
|
||||
rules: {
|
||||
...turboPlugin.configs.recommended.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'],
|
||||
'header/header': [
|
||||
'error',
|
||||
'block',
|
||||
[
|
||||
'*',
|
||||
' * Copyright 2025 LY Corporation',
|
||||
' *',
|
||||
' * LY Corporation licenses this file to you under the Apache License,',
|
||||
' * version 2.0 (the "License"); you may not use this file except in compliance',
|
||||
' * with the License. You may obtain a copy of the License at:',
|
||||
' *',
|
||||
' * https://www.apache.org/licenses/LICENSE-2.0',
|
||||
' *',
|
||||
' * Unless required by applicable law or agreed to in writing, software',
|
||||
' * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT',
|
||||
' * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the',
|
||||
' * License for the specific language governing permissions and limitations',
|
||||
' * under the License.',
|
||||
' ',
|
||||
],
|
||||
1,
|
||||
],
|
||||
'@typescript-eslint/no-empty-interface': 'off',
|
||||
'@typescript-eslint/no-empty-object-type': 'off',
|
||||
'@typescript-eslint/no-base-to-string': 'off',
|
||||
'@typescript-eslint/consistent-type-definitions': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
linterOptions: { reportUnusedDisableDirectives: true },
|
||||
languageOptions: { parserOptions: { projectService: true } },
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Copyright 2025 LY Corporation
|
||||
*
|
||||
* LY Corporation licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ['**/*.ts'],
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/unbound-method': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright 2025 LY Corporation
|
||||
*
|
||||
* LY Corporation licenses this file to you under the Apache License,
|
||||
* version 2.0 (the "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
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',
|
||||
'@next/next/no-html-link-for-pages': 'off',
|
||||
'@next/next/no-page-custom-font': 'off',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "@ufb/eslint-config",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"./base": "./base.js",
|
||||
"./nestjs": "./nestjs.js",
|
||||
"./nextjs": "./nextjs.js",
|
||||
"./react": "./react.js"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "git clean -xdf .cache .turbo node_modules",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@eslint/compat": "^2.0.3",
|
||||
"@next/eslint-plugin-next": "^16.2.1",
|
||||
"@ufb/eslint-plugin-header": "workspace:*",
|
||||
"eslint-plugin-import": "^2.32.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.10.2",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-compiler": "beta",
|
||||
"eslint-plugin-react-hooks": "^6.1.1",
|
||||
"eslint-plugin-turbo": "^2.8.3",
|
||||
"typescript-eslint": "^8.46.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ufb/prettier-config": "workspace:*",
|
||||
"@ufb/tsconfig": "workspace:*",
|
||||
"eslint": "catalog:",
|
||||
"prettier": "catalog:",
|
||||
"typescript": "catalog:"
|
||||
},
|
||||
"prettier": "@ufb/prettier-config"
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
import reactPlugin from 'eslint-plugin-react';
|
||||
import compilerPlugin from 'eslint-plugin-react-compiler';
|
||||
import hooksPlugin from 'eslint-plugin-react-hooks';
|
||||
|
||||
/** @type {Awaited<import('typescript-eslint').Config>} */
|
||||
export default [
|
||||
{
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
plugins: {
|
||||
react: reactPlugin,
|
||||
'react-compiler': compilerPlugin,
|
||||
'react-hooks': hooksPlugin,
|
||||
},
|
||||
rules: {
|
||||
...reactPlugin.configs['jsx-runtime'].rules,
|
||||
...hooksPlugin.configs.recommended.rules,
|
||||
'react/prop-types': 'off',
|
||||
'react/jsx-key': 'error',
|
||||
'react-hooks/exhaustive-deps': 'off',
|
||||
'react/display-name': 'off',
|
||||
'react-hooks/rules-of-hooks': 'off',
|
||||
'react-compiler/react-compiler': 'error',
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
React: 'writable',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "@ufb/tsconfig/base.json",
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
Vendored
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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-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-compiler' {}
|
||||
|
||||
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>;
|
||||
}
|
||||
Reference in New Issue
Block a user