Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand lint scripts #25251

Merged
merged 10 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function onDocumentLoad() {

}

prettyPrint();
prettyPrint(); // eslint-disable-line no-undef

};

Expand Down
4 changes: 2 additions & 2 deletions editor/js/Sidebar.Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ function SidebarAnimation( editor ) {
const name = new UIText( animation.name ).setWidth( '200px' );
container.add( name );

const button = new UIButton( getButtonText( action ) );
const button = new UIButton( getButtonText( action ) );
button.onClick( function () {

action.isRunning() ? action.stop() : action.play();
button.setTextContent( getButtonText( action ) );
button.setTextContent( getButtonText( action ) );

} );

Expand Down
2 changes: 1 addition & 1 deletion editor/js/Sidebar.Material.MapProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function SidebarMaterialMapProperty( editor, property, name ) {
let rangeMin, rangeMax;

if ( property === 'iridescenceThicknessMap' ) {

const range = new UIDiv().setMarginLeft( '3px' );
container.add( range );

Expand Down
4 changes: 2 additions & 2 deletions editor/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ async function networkFirst( request ) {
if ( request.url.endsWith( 'editor/' ) || request.url.endsWith( 'editor/index.html' ) ) { // copied from coi-serviceworker

const newHeaders = new Headers( response.headers );
newHeaders.set( "Cross-Origin-Embedder-Policy", "require-corp" );
newHeaders.set( "Cross-Origin-Opener-Policy", "same-origin" );
newHeaders.set( 'Cross-Origin-Embedder-Policy', 'require-corp' );
newHeaders.set( 'Cross-Origin-Opener-Policy', 'same-origin' );

response = new Response( response.body, { status: response.status, statusText: response.statusText, headers: newHeaders } );

Expand Down
66 changes: 51 additions & 15 deletions examples/jsm/loaders/PLYLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ class PLYLoader extends Loader {

function mapElementAttributes( properties ) {

const elementNames = properties.map( property => { return property.name } );
const elementNames = properties.map( property => {

return property.name;

} );

function findAttrName( names ) {

Expand Down Expand Up @@ -564,20 +568,52 @@ class PLYLoader extends Loader {
switch ( type ) {

// corespondences for non-specific length types here match rply:
case 'int8': case 'char': return { read: ( at ) => { return dataview.getInt8( at ) }, size: 1 };
case 'uint8': case 'uchar': return { read: ( at ) => { return dataview.getUint8( at ) }, size: 1 };
case 'int16': case 'short': return { read: ( at ) => { return dataview.getInt16( at, little_endian ) }, size: 2 };
case 'uint16': case 'ushort': return { read: ( at ) => { return dataview.getUint16( at, little_endian ) }, size: 2 };
case 'int32': case 'int': return { read: ( at ) => { return dataview.getInt32( at, little_endian ) }, size: 4 };
case 'uint32': case 'uint': return { read: ( at ) => { return dataview.getUint32( at, little_endian ) }, size: 4 };
case 'float32': case 'float': return { read: ( at ) => { return dataview.getFloat32( at, little_endian ) }, size: 4 };
case 'float64': case 'double': return { read: ( at ) => { return dataview.getFloat64( at, little_endian ) }, size: 8 };
case 'int8': case 'char': return { read: ( at ) => {

return dataview.getInt8( at );

}, size: 1 };
case 'uint8': case 'uchar': return { read: ( at ) => {

return dataview.getUint8( at );

}, size: 1 };
case 'int16': case 'short': return { read: ( at ) => {

return dataview.getInt16( at, little_endian );

}, size: 2 };
case 'uint16': case 'ushort': return { read: ( at ) => {

return dataview.getUint16( at, little_endian );

}, size: 2 };
case 'int32': case 'int': return { read: ( at ) => {

return dataview.getInt32( at, little_endian );

}, size: 4 };
case 'uint32': case 'uint': return { read: ( at ) => {

return dataview.getUint32( at, little_endian );

}, size: 4 };
case 'float32': case 'float': return { read: ( at ) => {

return dataview.getFloat32( at, little_endian );

}, size: 4 };
case 'float64': case 'double': return { read: ( at ) => {

return dataview.getFloat64( at, little_endian );

}, size: 8 };

}

}

for ( let i = 0, l = properties.length; i < l; i++ ) {
for ( let i = 0, l = properties.length; i < l; i ++ ) {

const property = properties[ i ];

Expand All @@ -594,7 +630,7 @@ class PLYLoader extends Loader {

}

};
}

function parseBinary( data, header ) {

Expand Down Expand Up @@ -638,9 +674,9 @@ class PLYLoader extends Loader {

do {

const c = String.fromCharCode( bytes[ i++ ] );
const c = String.fromCharCode( bytes[ i ++ ] );

if ( c !== "\n" && c !== "\r" ) {
if ( c !== '\n' && c !== '\r' ) {

line += c;

Expand All @@ -656,9 +692,9 @@ class PLYLoader extends Loader {

}

} while ( cont && i < bytes.length );
} while ( cont && i < bytes.length );

return lines.join( "\r" ) + "\r";
return lines.join( '\r' ) + '\r';

}

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/loaders/lwo/IFFParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ DataViewReader.prototype = {
result = this._textDecoder.decode( new Uint8Array( this.dv.buffer, start, length ) );

// account for null byte in length
length++;
length ++;

// if string with terminating nullbyte is uneven, extra nullbyte is added, skip that too
length += length % 2;
Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/renderers/webgpu/WebGPUGeometries.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class WebGPUGeometries {
}

getIndex( geometry, wireframe = false ) {

let index = geometry.index;

if ( wireframe ) {
Expand Down
21 changes: 16 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@
"QUnit": "readonly",
"Ammo": "readonly",
"XRRigidTransform": "readonly",
"XRMediaBinding": "readonly"
"XRMediaBinding": "readonly",
"CodeMirror": "readonly",
"esprima": "readonly",
"jsonlint": "readonly",
"Benchmark": "readonly",
"Bench": "readonly"
},
"rules": {
"no-throw-literal": [
Expand Down Expand Up @@ -97,10 +102,16 @@
"build": "rollup -c utils/build/rollup.config.js",
"build-module": "rollup -c utils/build/rollup.config.js --configOnlyModule",
"dev": "concurrently --names \"ROLLUP,HTTP\" -c \"bgBlue.bold,bgGreen.bold\" \"rollup -c utils/build/rollup.config.js -w -m inline\" \"servez -p 8080 --ssl\"",
"lint": "eslint src --ext js",
"lint-examples": "eslint examples/jsm examples/*.html --ext js,html --ignore-pattern libs --ignore-pattern ifc",
"lint-docs": "eslint docs --ext html",
"lint-fix": "npm run lint -- --fix && npm run lint-examples -- --fix && npm run lint-docs -- --fix",
"lint-core": "eslint src",
"lint-addons": "eslint examples/jsm --ext .js --ignore-pattern libs --ignore-pattern ifc",
"lint-examples": "eslint examples --ext .html",
"lint-docs": "eslint docs --ignore-pattern prettify.js",
"lint-editor": "eslint editor --ignore-pattern libs",
"lint-manual": "eslint manual --ignore-pattern 3rdparty --ignore-pattern prettify.js --ignore-pattern shapefile.js",
"lint-test": "eslint test --ignore-pattern vendor",
"lint-utils": "eslint utils",
"lint": "npm run lint-core",
"lint-fix": "npm run lint-core -- --fix && npm run lint-addons -- --fix && npm run lint-docs -- --fix",
"test-unit": "npm run unit --prefix test",
"test-e2e": "node test/e2e/puppeteer.js",
"test-e2e-cov": "node test/e2e/check-coverage.js",
Expand Down
6 changes: 3 additions & 3 deletions test/benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var BenchClass = function () {

BenchClass.prototype.isTHREELoaded = function () {

return _.isObject( this.THREE );
return _.isObject( this.THREE ); // eslint-disable-line no-undef

};

Expand Down Expand Up @@ -64,7 +64,7 @@ SuiteUI.prototype.render = function () {

SuiteUI.prototype.run = function () {

this.runButton.click = _.noop;
this.runButton.click = _.noop; // eslint-disable-line no-undef
this.runButton.innerText = 'Running...';
this.suite.on( 'complete', this.complete.bind( this ) );
this.suite.run( {
Expand All @@ -77,7 +77,7 @@ SuiteUI.prototype.complete = function () {

this.runButton.style.display = 'none';
this.results.style.display = 'block';
var f = _.orderBy( this.suite, [ 'hz' ], [ 'desc' ] );
var f = _.orderBy( this.suite, [ 'hz' ], [ 'desc' ] ); // eslint-disable-line no-undef
for ( var i = 0; i < f.length; i ++ ) {

var x = f[ i ];
Expand Down
8 changes: 8 additions & 0 deletions test/benchmark/core/Vector3Components.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@

}

return result;
Mugen87 marked this conversation as resolved.
Show resolved Hide resolved

} );

s.add( 'SwitchStatement', function () {
Expand All @@ -119,6 +121,8 @@

}

return result;

} );

s.add( 'IfAndReturnSeries', function () {
Expand All @@ -130,6 +134,8 @@

}

return result;

} );

s.add( 'IfReturnElseSeries', function () {
Expand All @@ -141,6 +147,8 @@

}

return result;

} );

} )();
6 changes: 6 additions & 0 deletions test/benchmark/core/Vector3Length.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@

}

return result;

} );

suite.add( 'InlineCallTest', function () {
Expand All @@ -63,6 +65,8 @@

}

return result;

} );

suite.add( 'FunctionCallTest', function () {
Expand All @@ -74,6 +78,8 @@

}

return result;

} );

} )();
6 changes: 6 additions & 0 deletions test/benchmark/core/Vector3Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@

}

return result;

} );

suite.add( 'Vector3-Float32Array', function () {
Expand All @@ -103,6 +105,8 @@

}

return result;

} );

suite.add( 'Vector3-Array', function () {
Expand All @@ -123,6 +127,8 @@

}

return result;

} );

} )();
4 changes: 2 additions & 2 deletions test/e2e/deterministic-injection.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const maxFrameId = 2;
window.requestAnimationFrame = function ( cb ) {

if ( ! _renderStarted ) {
if ( ! window._renderStarted ) {

setTimeout( function () {

Expand All @@ -52,7 +52,7 @@

} else {

_renderFinished = true;
window._renderFinished = true;

}

Expand Down
17 changes: 10 additions & 7 deletions test/unit/src/animation/AnimationAction.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,21 +445,23 @@ export default QUnit.module( 'Animation', () => {
} );

QUnit.test( 'StartAt when already executed once', ( assert ) => {

var root = new Object3D();
var mixer = new AnimationMixer( root );
var track = new NumberKeyframeTrack( '.rotation[x]', [ 0, 750 ], [ 0, 270 ] );
var clip = new AnimationClip( 'clip1', 750, [ track ] );

var animationAction = mixer.clipAction( clip );
animationAction.setLoop( LoopOnce );
animationAction.clampWhenFinished = true;
animationAction.play();
mixer.addEventListener('finished', () => {
animationAction.timeScale*=-1;
animationAction.paused=false;
animationAction.startAt(mixer.time+2000).play();
mixer.addEventListener( 'finished', () => {

animationAction.timeScale *= - 1;
animationAction.paused = false;
animationAction.startAt( mixer.time + 2000 ).play();

});
} );

mixer.update( 250 );
assert.equal( root.rotation.x, 90, 'first' );
Expand Down Expand Up @@ -488,7 +490,8 @@ export default QUnit.module( 'Animation', () => {
mixer.update( 250 );
assert.equal( root.rotation.x, 180, 'seventh' );
//console.log(mixer.time);
});

} );

} );

Expand Down
6 changes: 3 additions & 3 deletions test/unit/src/core/Object3D.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export default QUnit.module( 'Core', () => {
QUnit.test( 'Extending', ( assert ) => {

var object = new Object3D();

assert.strictEqual( object instanceof EventDispatcher, true, 'Object3D extends from EventDispatcher' );

} );

// INSTANCING
Expand Down Expand Up @@ -550,7 +550,7 @@ export default QUnit.module( 'Core', () => {
parent.add( childName, childNothing );

assert.strictEqual( parent.getObjectsByProperty( 'name', 'foo' ).length, 3, 'Get amount of all childs by name "foo"' );
assert.strictEqual( parent.getObjectsByProperty( 'name', 'foo' ).some(obj => obj.name !== 'foo') , false, 'Get all childs by name "foo"' );
assert.strictEqual( parent.getObjectsByProperty( 'name', 'foo' ).some( obj => obj.name !== 'foo' ), false, 'Get all childs by name "foo"' );

} );

Expand Down
Loading