Skip to content

Commit

Permalink
update packages and typescript config
Browse files Browse the repository at this point in the history
  • Loading branch information
gracepark committed Nov 13, 2024
1 parent 51a5db1 commit 1747fdb
Show file tree
Hide file tree
Showing 4 changed files with 693 additions and 4,554 deletions.
65 changes: 26 additions & 39 deletions lib/configs/flat/typescript.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,27 @@
const {FlatCompat} = require('@eslint/eslintrc')
const eslint = require('@eslint/js')
const tseslint = require('typescript-eslint')
const escompatPlugin = require('eslint-plugin-escompat')
const github = require('../../plugin')

const compat = new FlatCompat({resolvePluginsRelativeTo: __dirname})

const typescriptModule = {
...compat.config({
extends: ['plugin:@typescript-eslint/recommended', 'prettier', 'plugin:escompat/typescript-2020'],
plugins: ['@typescript-eslint', 'escompat'],
parser: '@typescript-eslint/parser',
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
'no-shadow': 'off',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': ['error'],
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
}),
}
// Need to merge to get the appropriate structure for the config
const mergedConfig = {}

for (const obj of Object.values(typescriptModule)) {
Object.assign(mergedConfig, {
languageOptions: {...mergedConfig.languageOptions, ...obj.languageOptions},
plugins: {...mergedConfig.plugins, ...obj.plugins},
rules: {...mergedConfig.rules, ...obj.rules},
files: [...(mergedConfig.files || []), ...(obj.files || [])],
})
}

module.exports = mergedConfig
module.exports = tseslint.config(eslint.configs.recommended, ...tseslint.configs.recommended, {
languageOptions: {
parser: tseslint.parser,
},
plugins: {'@typescript-eslint': tseslint.plugin, escompatPlugin, github},
rules: {
camelcase: 'off',
'no-unused-vars': 'off',
'no-shadow': 'off',
'no-invalid-this': 'off',
'@typescript-eslint/no-invalid-this': ['error'],
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/array-type': ['error', {default: 'array-simple'}],
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
})
Loading

0 comments on commit 1747fdb

Please sign in to comment.