Skip to content

Commit

Permalink
chore(lint): disallow Math.hypot, window, document (#8277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Sep 12, 2022
1 parent 938033a commit 2ef70cf
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 98 deletions.
22 changes: 22 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,27 @@ module.exports = {
],
rules: {
'@typescript-eslint/ban-ts-comment': 1,
'no-restricted-globals': [
'error',
{
name: 'window',
message: 'Use fabric window or other utils instead.'
},
{
name: 'document',
message: 'Use fabric document or other utils instead.'
}
],
'no-restricted-syntax': [
'error',
{
selector: '[callee.object.name="Math"][callee.property.name="hypot"]',
message: '`Math.hypot` is not accurate on chrome, import `hypot` from `util` instead.'
},
{
selector: 'VariableDeclarator[init.name="Math"]',
message: 'Aliasing or destructing `Math` is not allowed due to restrictions on `Math.hypot` usage.'
}
]
},
};
11 changes: 11 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,17 @@
{
"ignoreComments": true
}
],
"no-restricted-syntax": [
"error",
{
"selector": "[callee.object.name='Math'][callee.property.name='hypot']",
"message": "`Math.hypot` is not accurate on chrome, import `hypot` from `util` instead"
},
{
"selector": "VariableDeclarator[init.name='Math']",
"message": "Aliasing or destructing `Math` is not allowed due to restrictions on `Math.hypot` usage"
}
]
}
}

0 comments on commit 2ef70cf

Please sign in to comment.