2022-12-22 00:55:39 -08:00
|
|
|
/**
|
|
|
|
* @type {(dir: string, mode: 'frontend' | undefined) => import('@types/eslint').ESLint.ConfigData}
|
|
|
|
*/
|
2023-07-19 00:35:10 -07:00
|
|
|
module.exports = (tsconfigRootDir, mode) => {
|
2022-12-22 00:55:39 -08:00
|
|
|
const isFrontend = mode === 'frontend';
|
|
|
|
const parser = isFrontend ? 'vue-eslint-parser' : '@typescript-eslint/parser';
|
|
|
|
const extraParserOptions = isFrontend
|
|
|
|
? {
|
|
|
|
extraFileExtensions: ['.vue'],
|
|
|
|
parser: {
|
|
|
|
ts: '@typescript-eslint/parser',
|
|
|
|
js: '@typescript-eslint/parser',
|
|
|
|
vue: 'vue-eslint-parser',
|
|
|
|
template: 'vue-eslint-parser',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: {};
|
|
|
|
|
|
|
|
const settings = {
|
|
|
|
'import/parsers': {
|
2022-12-22 07:42:07 -08:00
|
|
|
'@typescript-eslint/parser': ['.ts'],
|
2022-12-22 00:55:39 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
'import/resolver': {
|
|
|
|
typescript: {
|
|
|
|
tsconfigRootDir,
|
|
|
|
project: './tsconfig.json',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
parser,
|
|
|
|
parserOptions: {
|
|
|
|
tsconfigRootDir,
|
|
|
|
project: ['./tsconfig.json'],
|
|
|
|
...extraParserOptions,
|
|
|
|
},
|
|
|
|
settings,
|
|
|
|
};
|
|
|
|
};
|