mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
3566c13afc
* feat: Allow `eslint-config` to be externally consumable * refactor: Adjust import styles
42 lines
874 B
JavaScript
42 lines
874 B
JavaScript
/**
|
|
* @type {(dir: string, mode: 'frontend' | undefined) => import('@types/eslint').ESLint.ConfigData}
|
|
*/
|
|
module.exports = (tsconfigRootDir, mode) => {
|
|
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': {
|
|
'@typescript-eslint/parser': ['.ts'],
|
|
},
|
|
|
|
'import/resolver': {
|
|
typescript: {
|
|
tsconfigRootDir,
|
|
project: './tsconfig.json',
|
|
},
|
|
},
|
|
};
|
|
|
|
return {
|
|
parser,
|
|
parserOptions: {
|
|
tsconfigRootDir,
|
|
project: ['./tsconfig.json'],
|
|
...extraParserOptions,
|
|
},
|
|
settings,
|
|
};
|
|
};
|