Browse Source

Fix lint command

Garrett Johnson 4 years ago
parent
commit
0282c204c4
3 changed files with 28 additions and 25 deletions
  1. 3 0
      .eslintrc.json
  2. 1 1
      package.json
  3. 24 24
      test/PriorityQueue.test.js

+ 3 - 0
.eslintrc.json

@@ -3,6 +3,9 @@
 	"parserOptions": {
         "ecmaVersion": 2018
 	},
+	"env": {
+		"jest/globals": true
+	},
 
 	"extends": "./node_modules/eslint-config-mdcs/index.js",
 	"plugins": [ "jest" ],

+ 1 - 1
package.json

@@ -22,7 +22,7 @@
   ],
   "scripts": {
     "start": "concurrently \"parcel watch example/*.html --out-dir ./example/bundle/ --public-url . --no-cache\" \"static-server\"",
-    "lint": "eslint src/**.js && tsc -p tsconfig.json --noEmit",
+    "lint": "eslint \"src/**/*.js\" \"test/**/*.js\" && tsc -p tsconfig.json --noEmit",
     "test": "jest"
   },
   "repository": {

+ 24 - 24
test/PriorityQueue.test.js

@@ -10,13 +10,13 @@ describe( 'PriorityQueue', () => {
 		const queue = new PriorityQueue();
 		queue.maxJobs = 6;
 		queue.priorityCallback = item => item.priority;
-		queue.add( { priority : 6 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 3 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 4 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 0 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 8 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 2 }, () => new Promise( () => {} ) );
-		queue.add( { priority : 1 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 6 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 3 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 4 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 0 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 8 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 2 }, () => new Promise( () => {} ) );
+		queue.add( { priority: 1 }, () => new Promise( () => {} ) );
 
 		await nextFrame();
 
@@ -38,13 +38,13 @@ describe( 'PriorityQueue', () => {
 		const queue = new PriorityQueue();
 		queue.maxJobs = 1;
 		queue.priorityCallback = item => item.priority;
-		queue.add( { priority : 6 }, cb );
-		queue.add( { priority : 3 }, cb );
-		queue.add( { priority : 4 }, cb );
-		queue.add( { priority : 0 }, cb );
-		queue.add( { priority : 8 }, cb );
-		queue.add( { priority : 2 }, cb );
-		queue.add( { priority : 1 }, cb );
+		queue.add( { priority: 6 }, cb );
+		queue.add( { priority: 3 }, cb );
+		queue.add( { priority: 4 }, cb );
+		queue.add( { priority: 0 }, cb );
+		queue.add( { priority: 8 }, cb );
+		queue.add( { priority: 2 }, cb );
+		queue.add( { priority: 1 }, cb );
 		expect( queue.items.length ).toEqual( queue.callbacks.size );
 
 		await nextTick();
@@ -56,10 +56,10 @@ describe( 'PriorityQueue', () => {
 
 	it( 'should remove an item from the queue correctly.', () => {
 
-		const A = { priority : 0 };
-		const B = { priority : 1 };
-		const C = { priority : 2 };
-		const D = { priority : 3 };
+		const A = { priority: 0 };
+		const B = { priority: 1 };
+		const C = { priority: 2 };
+		const D = { priority: 3 };
 		const queue = new PriorityQueue();
 		queue.priorityCallback = item => item.priority;
 		queue.add( A, () => new Promise( () => {} ) );
@@ -93,14 +93,14 @@ describe( 'PriorityQueue', () => {
 		queue.maxJobs = 1;
 		queue.priorityCallback = item => item.priority;
 
-		queue.add( { priority : 1 }, () => new Promise( resolve => {
+		queue.add( { priority: 1 }, () => new Promise( resolve => {
 
 			resolveFunc = resolve;
 			called ++;
 
 		} ) );
 
-		queue.add( { priority : 0 }, () => new Promise( () => {
+		queue.add( { priority: 0 }, () => new Promise( () => {
 
 			called ++;
 
@@ -124,7 +124,7 @@ describe( 'PriorityQueue', () => {
 
 	it( 'should fire the callback with the item and priority.', async () => {
 
-		const A = { priority : 100 };
+		const A = { priority: 100 };
 		const queue = new PriorityQueue();
 		queue.priorityCallback = item => item.priority;
 
@@ -138,13 +138,13 @@ describe( 'PriorityQueue', () => {
 
 	} );
 
-	it( 'should return a promise that resolves from the add function.',  async () => {
+	it( 'should return a promise that resolves from the add function.', async () => {
 
 		const queue = new PriorityQueue();
 		queue.priorityCallback = item => item.priority;
 
 		let result = null;
-		queue.add( { priority : 0 }, item => Promise.resolve( 1000 ) ).then( res => result = res );
+		queue.add( { priority: 0 }, item => Promise.resolve( 1000 ) ).then( res => result = res );
 
 		expect( result ).toEqual( null );
 
@@ -184,6 +184,6 @@ describe( 'PriorityQueue', () => {
 
 		expect( queue.items ).toHaveLength( 0 );
 
-	});
+	} );
 
 } );