Skip to content

Commit

Permalink
Update the ESLint config to v8 (#65)
Browse files Browse the repository at this point in the history
The ESLint config has been updated to v8. The lint scripts have been
updated to match the MetaMask module template, and all lint errors
have been fixed.

The config wasn't updated to v9 because that would involve writing
comments for everything. That can wait for a later PR, since all of
those manual changes would be difficult to review when mixed in with
these changes (which are mostly automatic fixes).

Most of the manual lint fixes were pretty straightforward, but one
notable case was the use of the bitwise OR operator. I saw that `| 0`
was used in a few different places to truncate anything after the
decimal point. `Math.floor` is now used instead, as it achieves the
same effect and is easier to understand.
  • Loading branch information
Gudahtt authored Oct 6, 2021
1 parent f928fe3 commit 4f09fa1
Show file tree
Hide file tree
Showing 21 changed files with 5,197 additions and 13,527 deletions.
38 changes: 16 additions & 22 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
module.exports = {
env: {
es6: true,
browser: true,
},
extends: [
'@metamask/eslint-config',
'@metamask/eslint-config/config/nodejs',
root: true,

extends: ['@metamask/eslint-config', '@metamask/eslint-config-nodejs'],

overrides: [
{
files: ['./example/*.js', './index.js', './util.js'],
globals: {
Blob: true,
document: true,
window: true,
},
},
],
plugins: [
'json',
],
parserOptions: {
ecmaVersion: 2018,
},
ignorePatterns: [
'!.eslintrc.js',
'node_modules/',
'bundle.js',
],
rules: {
'no-bitwise': 'off',
},
}

ignorePatterns: ['!.eslintrc.js', '!.prettierrc.js', 'bundle.js'],
};
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Created by https://www.gitignore.io/api/osx,node
# Optional eslint cache
.eslintcache

### OSX ###
.DS_Store
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// All of these are defaults except singleQuote, but we specify them
// for explicitness
module.exports = {
quoteProps: 'as-needed',
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
};
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ The sample app javascript is `bundle.js`, which is built from `sample.js` using
## API

```javascript
const ModelViewer = require('@metamask/logo')
const ModelViewer = require('@metamask/logo');

// To render with fixed dimensions:
const viewer = ModelViewer({

// Dictates whether width & height are px or multiplied
pxNotRatio: true,
width: 500,
Expand All @@ -28,24 +27,23 @@ const viewer = ModelViewer({

// head should slowly drift (overrides lookAt)
slowDrift: false,

})
});

// add viewer to DOM
const container = document.getElementById('logo-container')
container.appendChild(viewer.container)
const container = document.getElementById('logo-container');
container.appendChild(viewer.container);

// look at something on the page
viewer.lookAt({
x: 100,
y: 100,
})
});

// enable mouse follow
viewer.setFollowMouse(true)
viewer.setFollowMouse(true);

// deallocate nicely
viewer.stopAnimation()
viewer.stopAnimation();
```

## Running Example
Expand Down
Loading

0 comments on commit 4f09fa1

Please sign in to comment.