Skip to content

Commit

Permalink
feat: migrate typescript config
Browse files Browse the repository at this point in the history
  • Loading branch information
xobotyi committed Nov 25, 2024
1 parent 7c8396e commit 5571ced
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 125 deletions.
1 change: 1 addition & 0 deletions configs/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const baseConfig = [

// Conflicts with prettier
'@stylistic/object-curly-spacing': 'off',
'@stylistic/quotes': 'off',
},
},
eslintPluginPrettierRecommended,
Expand Down
17 changes: 16 additions & 1 deletion configs/typescript-unsafe.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
const typescriptUnsafeConfig = [];
import typescriptConfig from './typescript.js';

const typescriptUnsafeConfig = [
...typescriptConfig,
{
rules: {
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-declaration-merging': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
},
},
];
export default typescriptUnsafeConfig;
106 changes: 105 additions & 1 deletion configs/typescript.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,106 @@
const typescriptConfig = [];
import xoTypescript from 'eslint-config-xo-typescript';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import baseConfig from './base.js';

const typescriptConfig = [
...baseConfig,

xoTypescript,
{
rules: {
'import/consistent-type-specifier-style': ['error', 'prefer-inline'],

'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/promise-function-async': 'off',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'variable',
modifiers: ['destructured'],
// eslint-disable-next-line unicorn/no-null
format: null,
},
{
selector: [
'classProperty',
'objectLiteralProperty',
'typeProperty',
'classMethod',
'objectLiteralMethod',
'typeMethod',
'accessor',
'enumMember',
],
// eslint-disable-next-line unicorn/no-null
format: null,
modifiers: ['requiresQuotes'],
},
{
selector: 'variable',
modifiers: ['const', 'global'],
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
prefer: 'type-imports',
},
],
'@typescript-eslint/ban-types': [
'error',
{
extendDefaults: false,
types: {
String: {
message: 'Use `string` instead.',
fixWith: 'string',
},
Number: {
message: 'Use `number` instead.',
fixWith: 'number',
},
Boolean: {
message: 'Use `boolean` instead.',
fixWith: 'boolean',
},
Symbol: {
message: 'Use `symbol` instead.',
fixWith: 'symbol',
},
BigInt: {
message: 'Use `bigint` instead.',
fixWith: 'bigint',
},
Object: {
message:
'The `Object` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead. See https://github.com/typescript-eslint/typescript-eslint/pull/848',
fixWith: 'Record<string, unknown>',
},
'{}': {
message:
'The `{}` type is mostly the same as `unknown`. You probably want `Record<string, unknown>` instead.',
fixWith: 'Record<string, unknown>',
},
object: {
message:
'The `object` type is hard to use. Use `Record<string, unknown>` instead. See: https://github.com/typescript-eslint/typescript-eslint/pull/848',
fixWith: 'Record<string, unknown>',
},
Function: 'Use a specific function type instead, like `() => void`.',
'[[]]':
"Don't use `[[]]`. It only allows an array with a single element which is an empty array. Use `SomeType[][]` instead.",
'[[[]]]': "Don't use `[[[]]]`. Use `SomeType[][][]` instead.",
'[[[[]]]]': 'ur drunk 🤡',
'[[[[[]]]]]': '🦄💥',
},
},
],
},
},

eslintPluginPrettierRecommended,
];
export default typescriptConfig;
12 changes: 0 additions & 12 deletions typescript-unsafe.cjs

This file was deleted.

111 changes: 0 additions & 111 deletions typescript.cjs

This file was deleted.

0 comments on commit 5571ced

Please sign in to comment.