mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
ci: Setup eslint-import-resolver-typescript for improved TS linting (#4996)
* Setup stricter linting for typescript * make `import/no-unresolved` an error everywhere * use prettier to format `.vscode/settings.default.json` * address PR comments
This commit is contained in:
committed by
GitHub
parent
9568b747c7
commit
17f13b3b6e
@@ -2,12 +2,6 @@
|
||||
* @type {import('@types/eslint').ESLint.ConfigData}
|
||||
*/
|
||||
const config = (module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
sourceType: 'module',
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
|
||||
ignorePatterns: [
|
||||
'node_modules/**',
|
||||
'dist/**',
|
||||
@@ -318,11 +312,21 @@ const config = (module.exports = {
|
||||
// eslint-plugin-import
|
||||
// ----------------------------------
|
||||
|
||||
/**
|
||||
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md
|
||||
*/
|
||||
'import/no-cycle': 'error',
|
||||
|
||||
/**
|
||||
* https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/no-default-export.md
|
||||
*/
|
||||
'import/no-default-export': 'error',
|
||||
|
||||
/**
|
||||
* https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md
|
||||
*/
|
||||
'import/no-unresolved': 'error',
|
||||
|
||||
/**
|
||||
* https://github.com/import-js/eslint-plugin-import/blob/master/docs/rules/order.md
|
||||
*/
|
||||
|
||||
@@ -12,16 +12,6 @@ module.exports = {
|
||||
node: true,
|
||||
},
|
||||
|
||||
parser: 'vue-eslint-parser',
|
||||
parserOptions: {
|
||||
parser: {
|
||||
ts: '@typescript-eslint/parser',
|
||||
js: '@typescript-eslint/parser',
|
||||
vue: 'vue-eslint-parser',
|
||||
template: 'vue-eslint-parser',
|
||||
},
|
||||
},
|
||||
|
||||
ignorePatterns: ['**/*.js', '**/*.d.ts', 'vite.config.ts', '**/*.ts.snap'],
|
||||
|
||||
rules: {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"eslint": "~8.28",
|
||||
"eslint-config-airbnb-typescript": "~17.0",
|
||||
"eslint-config-prettier": "~8.5",
|
||||
"eslint-import-resolver-typescript": "~3.5",
|
||||
"eslint-plugin-diff": "~2.0",
|
||||
"eslint-plugin-import": "~2.26",
|
||||
"eslint-plugin-n8n-local-rules": "~1.0",
|
||||
|
||||
41
packages/@n8n_io/eslint-config/shared.js
Normal file
41
packages/@n8n_io/eslint-config/shared.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @type {(dir: string, mode: 'frontend' | undefined) => import('@types/eslint').ESLint.ConfigData}
|
||||
*/
|
||||
exports.sharedOptions = (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': isFrontend ? ['.ts', '.vue'] : ['.ts'],
|
||||
},
|
||||
|
||||
'import/resolver': {
|
||||
typescript: {
|
||||
tsconfigRootDir,
|
||||
project: './tsconfig.json',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
return {
|
||||
parser,
|
||||
parserOptions: {
|
||||
tsconfigRootDir,
|
||||
project: ['./tsconfig.json'],
|
||||
...extraParserOptions,
|
||||
},
|
||||
settings,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user