Skip to content

Commit

Permalink
🏗✨ Adopt prettier for code formatting (#21212)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsimha authored May 16, 2019
1 parent 1e66423 commit c4a663d
Show file tree
Hide file tree
Showing 1,623 changed files with 138,754 additions and 110,981 deletions.
6 changes: 1 addition & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ firebase
third_party
test/coverage
**/*.extern.js
validator/dist
validator/webui/dist
validator/node_modules
validator/nodejs/node_modules
validator/webui/node_modules
validator/
eslint-rules
babel.config.js
karma.conf.js
Expand Down
41 changes: 8 additions & 33 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"google-camelcase",
"jsdoc",
"notice",
"prettier",
"sort-imports-es6-autofix",
"sort-requires"
],
Expand Down Expand Up @@ -76,33 +77,18 @@
"amphtml-internal/todo-format": 0,
"amphtml-internal/unused-private-field": 0,
"amphtml-internal/vsync": 0,
"array-bracket-spacing": [2, "never"],
"arrow-parens": [2, "as-needed"],
"arrow-spacing": 2,
"chai-expect/missing-assertion": 2,
"chai-expect/no-inner-compare": 2,
"chai-expect/terminating-properties": 2,
"comma-dangle": [2, "always-multiline"],
"computed-property-spacing": [2, "never"],
"curly": 2,
"dot-location": [2, "property"],
"eol-last": 2,
"google-camelcase/google-camelcase": 2,
"indent": [2, 2, { "SwitchCase": 1, "VariableDeclarator": 2, "MemberExpression": 2, "ObjectExpression": 1, "CallExpression": { "arguments": 2 } }],
"jsdoc/check-param-names": 2,
"jsdoc/check-tag-names": 2,
"jsdoc/check-types": 2,
"jsdoc/require-param": 2,
"jsdoc/require-param-name": 2,
"jsdoc/require-param-type": 2,
"jsdoc/require-returns-type": 2,
"key-spacing": 2,
"max-len": [2, 80, 4, {
"ignoreTrailingComments": true,
"ignoreRegExpLiterals": true,
"ignorePattern": "^} from.*;|= require\\(.*;$|@typedef|@param|@return|@private|@const|@type|@implements",
"ignoreUrls": true
}],
"no-alert": 2,
"no-cond-assign": 2,
"no-debugger": 2,
Expand All @@ -111,21 +97,17 @@
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-semi": 2,
"no-implicit-coercion": [2, { "boolean": false }],
"no-implied-eval": 2,
"no-iterator": 2,
"no-lone-blocks": 2,
"no-multi-spaces": 2,
"no-native-reassign": 2,
"no-redeclare": 2,
"no-restricted-globals": [2, "error", "event"],
"no-script-url": 2,
"no-self-compare": 2,
"no-sequences": 2,
"no-spaced-func": 2,
"no-throw-literal": 2,
"no-trailing-spaces": 2,
"no-unused-expressions": 0,
"no-unused-vars": [2, {
"argsIgnorePattern": "^(var_args$|opt_|unused)",
Expand All @@ -145,13 +127,14 @@
}
}
],
"object-curly-spacing": [2, "never", {
"objectsInObjects": false,
"arraysInObjects": false
}],
"object-shorthand": [2, "properties", { "avoidQuotes": true }],
"prefer-const": 2,
"quotes": [2, "single", "avoid-escape"],
"prettier/prettier": [2, {
"bracketSpacing": false,
"singleQuote": true,
"trailingComma": "es5",
"quoteProps": "preserve"
}],
"radix": 2,
"require-jsdoc": [2, {
"require": {
Expand All @@ -162,20 +145,12 @@
"FunctionExpression": false
}
}],
"semi": 2,
"keyword-spacing": [2, { "before": true, "after": true }],
"sort-imports-es6-autofix/sort-imports-es6": [2, {
"ignoreCase": false,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}],
"sort-requires/sort-requires": 2,
"space-before-blocks": 2,
"space-before-function-paren": [2, "never"],
"space-in-parens": 2,
"space-infix-ops": 2,
"space-unary-ops": [1, { "words": true, "nonwords": false }],
"wrap-iife": [2, "any"]
"sort-requires/sort-requires": 2
},
"overrides": [
{
Expand Down
33 changes: 20 additions & 13 deletions 3p/3d-gltf/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ const loadThree = (global, cb) => {
const loadScriptCb = url => cb => loadScript(global, url, cb);
const loadThreeExample = examplePath =>
loadScriptCb(
'https://cdn.jsdelivr.net/npm/three@0.91/examples/js/' + examplePath);
'https://cdn.jsdelivr.net/npm/three@0.91/examples/js/' + examplePath
);

seq(
loadScriptCb(
'https://cdnjs.cloudflare.com/ajax/libs/three.js/91/three.js'),
parallel(
loadThreeExample('loaders/GLTFLoader.js'),
loadThreeExample('controls/OrbitControls.js'))
loadScriptCb('https://cdnjs.cloudflare.com/ajax/libs/three.js/91/three.js'),
parallel(
loadThreeExample('loaders/GLTFLoader.js'),
loadThreeExample('controls/OrbitControls.js')
)
)(cb);
};

Expand All @@ -65,16 +66,22 @@ export function gltfViewer(global) {
if (!e.lengthComputable) {
return;
}
nonSensitiveDataPostMessage('progress', dict({
'total': e.total,
'loaded': e.loaded,
}));
nonSensitiveDataPostMessage(
'progress',
dict({
'total': e.total,
'loaded': e.loaded,
})
);
},
onerror: err => {
user().error('3DGLTF', err);
nonSensitiveDataPostMessage('error', dict({
'error': (err || '').toString(),
}));
nonSensitiveDataPostMessage(
'error',
dict({
'error': (err || '').toString(),
})
);
},
});
listenParent(global, 'action', msg => {
Expand Down
88 changes: 46 additions & 42 deletions 3p/3d-gltf/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import AnimationLoop from './animation-loop';

const CAMERA_DISTANCE_FACTOR = 1;
const CAMERA_FAR_FACTOR = 50;
const CAMERA_NEAR_FACTOR = .1;

const CAMERA_NEAR_FACTOR = 0.1;

export default class GltfViewer {
/**
Expand All @@ -45,8 +44,9 @@ export default class GltfViewer {

/** @private */
this.controls_ = new THREE.OrbitControls(
this.camera_,
this.renderer_.domElement);
this.camera_,
this.renderer_.domElement
);

/** @private */
this.scene_ = new THREE.Scene();
Expand All @@ -59,7 +59,7 @@ export default class GltfViewer {

/** @private */
this.ampInViewport_ =
options['initialIntersection']['intersectionRatio'] > 0;
options['initialIntersection']['intersectionRatio'] > 0;

/** @private */
this.setSize_ = this.setupSize_();
Expand All @@ -86,17 +86,20 @@ export default class GltfViewer {
* @private
*/
setModelRotation_(args) {
const xAngle = 'x' in args
? this.getModelRotationOnAxis_(args, 'x')
: this.model_.rotation.x;
const xAngle =
'x' in args
? this.getModelRotationOnAxis_(args, 'x')
: this.model_.rotation.x;

const yAngle = 'y' in args
? this.getModelRotationOnAxis_(args, 'y')
: this.model_.rotation.y;
const yAngle =
'y' in args
? this.getModelRotationOnAxis_(args, 'y')
: this.model_.rotation.y;

const zAngle = 'z' in args
? this.getModelRotationOnAxis_(args, 'z')
: this.model_.rotation.z;
const zAngle =
'z' in args
? this.getModelRotationOnAxis_(args, 'z')
: this.model_.rotation.z;

this.model_.rotation.set(xAngle, yAngle, zAngle);
this.animationLoop_.needsUpdate = true;
Expand Down Expand Up @@ -161,12 +164,12 @@ export default class GltfViewer {
*
* @private */
setupLight_() {
const amb = new THREE.AmbientLight(0xEDECD5, .5);
const amb = new THREE.AmbientLight(0xedecd5, 0.5);
const dir1 = new THREE.DirectionalLight(0xFFFFFF, .5);
const dir1 = new THREE.DirectionalLight(0xffffff, 0.5);
dir1.position.set(0, 5, 3);
const dir2 = new THREE.DirectionalLight(0xAECDD6, .4);
const dir2 = new THREE.DirectionalLight(0xaecdd6, 0.4);
dir2.position.set(-1, -2, 4);
const light = new THREE.Group();
Expand All @@ -188,12 +191,14 @@ export default class GltfViewer {
this.renderer_.gammaOutput = true;
this.renderer_.gammaFactor = 2.2;
this.renderer_.setPixelRatio(
Math.min(
this.options_['rendererSettings']['maxPixelRatio'],
devicePixelRatio));
Math.min(
this.options_['rendererSettings']['maxPixelRatio'],
devicePixelRatio
)
);
this.renderer_.setClearColor(
this.options_['rendererSettings']['clearColor'],
this.options_['rendererSettings']['clearAlpha']
this.options_['rendererSettings']['clearColor'],
this.options_['rendererSettings']['clearAlpha']
);
}
Expand Down Expand Up @@ -222,9 +227,9 @@ export default class GltfViewer {
this.camera_.far = sizeLength * CAMERA_FAR_FACTOR;
this.camera_.near = sizeLength * CAMERA_NEAR_FACTOR;
this.camera_.position.lerpVectors(
center,
bbox.max,
1 + CAMERA_DISTANCE_FACTOR
center,
bbox.max,
1 + CAMERA_DISTANCE_FACTOR
);
this.camera_.lookAt(center);

Expand All @@ -240,23 +245,22 @@ export default class GltfViewer {
loader.crossOrigin = true;

loader.load(
this.options_['src'],
/** @param {{scene: !THREE.Scene}} gltfData */
gltfData => {
this.setupCameraForObject_(gltfData.scene);
gltfData.scene.children
.slice()
.forEach(child => {
this.model_.add(child);
});

this.scene_.add(this.model_);

this.animationLoop_.needsUpdate = true;
this.handlers_.onload();
},
this.handlers_.onprogress,
this.handlers_.onerror);
this.options_['src'],
/** @param {{scene: !THREE.Scene}} gltfData */
gltfData => {
this.setupCameraForObject_(gltfData.scene);
gltfData.scene.children.slice().forEach(child => {
this.model_.add(child);
});

this.scene_.add(this.model_);

this.animationLoop_.needsUpdate = true;
this.handlers_.onload();
},
this.handlers_.onprogress,
this.handlers_.onerror
);
}

/** @private */
Expand Down
Loading

0 comments on commit c4a663d

Please sign in to comment.