提交 f604fbf3 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi

Make eslint work universally both for JS and TS code

上级 43b32370
...@@ -175,71 +175,59 @@ const eslintConfig = ...@@ -175,71 +175,59 @@ const eslintConfig =
'strict' : 2, 'strict' : 2,
'valid-typeof' : 2, 'valid-typeof' : 2,
'yoda' : 2 'yoda' : 2
} },
overrides : []
}; };
switch (process.env.MEDIASOUP_NODE_LANGUAGE) eslintConfig.overrides.push({
{ files : [ '*.ts' ],
case 'typescript': parser : '@typescript-eslint/parser',
{ plugins : [
eslintConfig.parser = '@typescript-eslint/parser'; ...eslintConfig.plugins,
eslintConfig.plugins = '@typescript-eslint'
[ ],
...eslintConfig.plugins, extends : [
'@typescript-eslint' 'eslint:recommended',
]; 'plugin:@typescript-eslint/eslint-recommended',
eslintConfig.extends = 'plugin:@typescript-eslint/recommended'
[ ],
'eslint:recommended', rules : {
'plugin:@typescript-eslint/eslint-recommended', ...eslintConfig.rules,
'plugin:@typescript-eslint/recommended' 'no-unused-vars' : 0,
]; '@typescript-eslint/ban-types' : 0,
eslintConfig.rules = '@typescript-eslint/ban-ts-comment' : 0,
{ '@typescript-eslint/ban-ts-ignore' : 0,
...eslintConfig.rules, '@typescript-eslint/explicit-module-boundary-types' : 0,
'no-unused-vars' : 0, '@typescript-eslint/member-delimiter-style' : [ 2,
'@typescript-eslint/ban-types' : 0, {
'@typescript-eslint/ban-ts-comment' : 0, multiline : { delimiter: 'semi', requireLast: true },
'@typescript-eslint/ban-ts-ignore' : 0, singleline : { delimiter: 'semi', requireLast: false }
'@typescript-eslint/explicit-module-boundary-types' : 0, }
'@typescript-eslint/member-delimiter-style' : [ 2, ],
{ '@typescript-eslint/no-explicit-any' : 0,
multiline : { delimiter: 'semi', requireLast: true }, '@typescript-eslint/no-unused-vars' : [ 2,
singleline : { delimiter: 'semi', requireLast: false } {
} vars : 'all',
], args : 'after-used',
'@typescript-eslint/no-explicit-any' : 0, ignoreRestSiblings : false
'@typescript-eslint/no-unused-vars' : [ 2, }
{ ],
vars : 'all', '@typescript-eslint/no-use-before-define' : [ 2, { functions: false } ],
args : 'after-used', '@typescript-eslint/no-empty-function' : 0,
ignoreRestSiblings : false '@typescript-eslint/no-non-null-assertion' : 0
}
],
'@typescript-eslint/no-use-before-define' : [ 2, { functions: false } ],
'@typescript-eslint/no-empty-function' : 0,
'@typescript-eslint/no-non-null-assertion' : 0
};
break;
}
case 'javascript':
{
eslintConfig.env['jest/globals'] = true;
eslintConfig.plugins =
[
...eslintConfig.plugins,
'jest'
];
break;
} }
});
default: eslintConfig.overrides.push({
{ files : [ '*.js' ],
throw new TypeError('wrong/missing MEDIASOUP_NODE_LANGUAGE env'); env : {
} ...eslintConfig.env,
} 'jest/globals' : true
},
plugins : [
...eslintConfig.plugins,
'jest'
]
});
module.exports = eslintConfig; module.exports = eslintConfig;
...@@ -69,8 +69,7 @@ switch (task) ...@@ -69,8 +69,7 @@ switch (task)
case 'lint:node': case 'lint:node':
{ {
execute('cross-env MEDIASOUP_NODE_LANGUAGE=typescript eslint -c node/.eslintrc.js --max-warnings 0 --ext=ts node/src/'); execute('eslint -c node/.eslintrc.js --max-warnings 0 node/src/ node/.eslintrc.js npm-scripts.js node/tests/ worker/scripts/gulpfile.js');
execute('cross-env MEDIASOUP_NODE_LANGUAGE=javascript eslint -c node/.eslintrc.js --max-warnings 0 --ext=js --ignore-pattern \'!node/.eslintrc.js\' node/.eslintrc.js npm-scripts.js node/tests/ worker/scripts/gulpfile.js');
break; break;
} }
......
...@@ -83,7 +83,6 @@ ...@@ -83,7 +83,6 @@
"@types/uuid": "^8.3.1", "@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.33.0", "@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0", "@typescript-eslint/parser": "^4.33.0",
"cross-env": "^7.0.3",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-jest": "^25.0.5", "eslint-plugin-jest": "^25.0.5",
"jest": "^27.2.5", "jest": "^27.2.5",
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论