Add typescript

(cherry picked from commit 910511dba03196f14bb238c8e15f060c12183c08)
This commit is contained in:
Mark McDowall 2023-01-05 18:43:51 -08:00 committed by Bogdan
commit eacaf9be32
17 changed files with 635 additions and 38 deletions

View file

@ -1,5 +1,9 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin').configs.recommended;
const frontendFolder = __dirname;
@ -44,7 +48,8 @@ module.exports = {
'react',
'react-hooks',
'simple-import-sort',
'import'
'import',
'@typescript-eslint'
],
settings: {
@ -227,7 +232,7 @@ module.exports = {
'consistent-this': ['error', 'self'],
'eol-last': 'error',
'func-names': 'off',
'func-style': ['error', 'declaration'],
'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
indent: ['error', 2, { SwitchCase: 1 }],
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
'keyword-spacing': ['error', { before: true, after: true }],
@ -318,7 +323,9 @@ module.exports = {
},
overrides: [
{
files: ['*.js'],
files: [
'*.js'
],
rules: {
'simple-import-sort/imports': [
'error',
@ -333,6 +340,47 @@ module.exports = {
}
]
}
},
{
files: [
'*.ts',
'*.tsx'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json'
},
rules: Object.assign(typescriptEslintRecommended.rules, {
'no-shadow': 'off',
// These should be enabled after cleaning things up
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'react/prop-types': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Packages
// Absolute Paths
// Relative Paths
// Css
['^@?\\w', `^(${dirs})(/.*|$)`, '^\\.', '^\\..*css$']
]
}
]
})
},
{
files: [
'*.css.d.ts'
],
rules: {
'filenames/match-exported': 'off',
'init-declarations': 'off',
'prettier/prettier': 'off'
}
}
]
};