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

Make eslint work universally both for JS and TS code

上级 43b32370
...@@ -175,27 +175,23 @@ const eslintConfig = ...@@ -175,27 +175,23 @@ 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, ...eslintConfig.plugins,
'@typescript-eslint' '@typescript-eslint'
]; ],
eslintConfig.extends = extends : [
[
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended', 'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended' 'plugin:@typescript-eslint/recommended'
]; ],
eslintConfig.rules = rules : {
{
...eslintConfig.rules, ...eslintConfig.rules,
'no-unused-vars' : 0, 'no-unused-vars' : 0,
'@typescript-eslint/ban-types' : 0, '@typescript-eslint/ban-types' : 0,
...@@ -219,27 +215,19 @@ switch (process.env.MEDIASOUP_NODE_LANGUAGE) ...@@ -219,27 +215,19 @@ switch (process.env.MEDIASOUP_NODE_LANGUAGE)
'@typescript-eslint/no-use-before-define' : [ 2, { functions: false } ], '@typescript-eslint/no-use-before-define' : [ 2, { functions: false } ],
'@typescript-eslint/no-empty-function' : 0, '@typescript-eslint/no-empty-function' : 0,
'@typescript-eslint/no-non-null-assertion' : 0 '@typescript-eslint/no-non-null-assertion' : 0
};
break;
} }
});
case 'javascript': eslintConfig.overrides.push({
{ files : [ '*.js' ],
eslintConfig.env['jest/globals'] = true; env : {
eslintConfig.plugins = ...eslintConfig.env,
[ 'jest/globals' : true
},
plugins : [
...eslintConfig.plugins, ...eslintConfig.plugins,
'jest' 'jest'
]; ]
});
break;
}
default:
{
throw new TypeError('wrong/missing MEDIASOUP_NODE_LANGUAGE env');
}
}
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 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论