1+ const asyncKeywordConstraintMsg =
2+ 'The async keyword adds a `regenerator` dependency in the hls.js ES5 output not allowed in v1 due to bundle size constraints.' ;
3+ const selfVsWindowGlobalMsg =
4+ 'Use `self` instead of `window` to access the global context everywhere (including workers).' ;
5+ const arrayFindCompatibilityMsg =
6+ 'Usage of Array find methods is restricted for compatibility.' ;
7+ const arrayFindIndexCompatibilityMsg =
8+ 'Usage of Array findIndex methods is restricted for compatibility.' ;
9+
110module . exports = {
211 env : { browser : true , commonjs : true , es6 : true } ,
312 globals : {
@@ -27,20 +36,13 @@ module.exports = {
2736 2 ,
2837 {
2938 name : 'window' ,
30- message :
31- 'Use `self` instead of `window` to access the global context everywhere (including workers).' ,
39+ message : selfVsWindowGlobalMsg ,
3240 } ,
3341 { name : 'SourceBuffer' , message : 'Use `self.SourceBuffer`' } ,
3442 { name : 'setTimeout' , message : 'Use `self.setTimeout`' } ,
3543 { name : 'setInterval' , message : 'Use `self.setInterval`' } ,
3644 ] ,
3745
38- 'no-restricted-properties' : [
39- 2 ,
40- { property : 'findIndex' } , // Intended to block usage of Array.prototype.findIndex
41- { property : 'find' } , // Intended to block usage of Array.prototype.find
42- ] ,
43-
4446 'import/first' : 1 ,
4547 'no-var' : 1 ,
4648 'no-empty' : 1 ,
@@ -67,6 +69,31 @@ module.exports = {
6769 'no-unused-vars' : 0 ,
6870 'no-undef' : 0 ,
6971 'no-use-before-define' : 'off' ,
72+ 'no-restricted-syntax' : [
73+ 'error' ,
74+ {
75+ selector : 'FunctionDeclaration[async=true]' ,
76+ message : asyncKeywordConstraintMsg ,
77+ } ,
78+ {
79+ selector : 'ArrowFunctionExpression[async=true]' ,
80+ message : asyncKeywordConstraintMsg ,
81+ } ,
82+ {
83+ selector : 'MethodDefinition[value.async=true]' ,
84+ message : asyncKeywordConstraintMsg ,
85+ } ,
86+ {
87+ selector :
88+ 'MemberExpression[property.name="find"][object.type="Identifier"]' ,
89+ message : arrayFindCompatibilityMsg ,
90+ } ,
91+ {
92+ selector :
93+ 'MemberExpression[property.name="findIndex"][object.type="Identifier"]' ,
94+ message : arrayFindIndexCompatibilityMsg ,
95+ } ,
96+ ] ,
7097 'import/order' : [
7198 'warn' ,
7299 {
@@ -98,6 +125,8 @@ module.exports = {
98125 '@typescript-eslint/consistent-type-imports' : 'error' ,
99126 '@typescript-eslint/no-import-type-side-effects' : 'error' ,
100127 '@typescript-eslint/no-restricted-imports' : 'error' ,
128+ '@typescript-eslint/no-floating-promises' : 'error' ,
129+ '@typescript-eslint/no-misused-promises' : 'error' ,
101130 } ,
102131 } ,
103132 ] ,
0 commit comments