Skip to content

Commit 5fab067

Browse files
committed
Added eslint
1 parent fea98ae commit 5fab067

20 files changed

+948
-1039
lines changed

.prettierrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": false,
4+
"htmlWhitespaceSensitivity": "css",
5+
"insertPragma": false,
6+
"jsxBracketSameLine": false,
7+
"jsxSingleQuote": false,
8+
"parser": "typescript",
9+
"printWidth": 80,
10+
"proseWrap": "preserve",
11+
"quoteProps": "as-needed",
12+
"requirePragma": false,
13+
"semi": false,
14+
"singleQuote": true,
15+
"tabWidth": 4,
16+
"trailingComma": "none",
17+
"useTabs": false
18+
}

.vscode/settings.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"eslint.provideLintTask": true,
4+
"eslint.validate": ["javascript", "typescript"]
5+
}

release/nano.js

+2
Original file line numberDiff line numberDiff line change
@@ -733,9 +733,11 @@ var Sprite = /** @class */ (function (_super) {
733733
_this.canvas = document.createElement('canvas');
734734
_this.graphics = _this.canvas.getContext('2d');
735735
_this._image = document.createElement('img');
736+
_this._image.crossOrigin = 'anonymous';
736737
_this._image.onload = function () { _this._isDirty = true; };
737738
_this._image.onerror = function () { _this._image.src = ""; };
738739
_this._mask = document.createElement('img');
740+
_this._mask.crossOrigin = 'anonymous';
739741
_this._mask.onload = function () { _this._isDirty = true; };
740742
_this._mask.onerror = function () { _this._mask.src = ""; };
741743
return _this;

release/nano.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Display/AnchorType.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
export enum AnchorType
2-
{
1+
export enum AnchorType {
32
NONE,
43
BOTTOM_CENTER,
54
BOTTOM_LEFT,
@@ -10,4 +9,4 @@ export enum AnchorType
109
TOP_CENTER,
1110
TOP_LEFT,
1211
TOP_RIGHT
13-
}
12+
}

src/Display/BlendMode.ts

+28-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
export enum BlendMode
2-
{
3-
SOURCE_OVER = "source-over",
4-
SOURCE_IN = "source-in",
5-
SOURCE_OUT = "source-out",
6-
SOURCE_ATOP = "source-atop",
7-
DESTINATION_OVER = "destination-over",
8-
DESTINATION_IN = "destination-in",
9-
DESTINATION_OUT = "destination-out",
10-
DESTINATION_ATOP = "destination-atop",
11-
LIGHTER = "lighter",
12-
COPY = "copy",
13-
XOR = "xor",
14-
MULTIPLY = "multiply",
15-
SCREEN = "screen",
16-
OVERLAY = "overlay",
17-
DARKEN = "darken",
18-
LIGHTEN = "lighten",
19-
COLOR_DODGE = "color-dodge",
20-
COLOR_BURN = "color-burn",
21-
HARD_LIGHT = "hard-light",
22-
SOFT_LIGHT = "soft-light",
23-
DIFFERENCE = "difference",
24-
EXCLUSION = "exclusion",
25-
HUE = "hue",
26-
SATURATION = "saturation",
27-
COLOR = "color",
28-
LUMINOSITY = "luminosity"
29-
}
1+
export enum BlendMode {
2+
SOURCE_OVER = 'source-over',
3+
SOURCE_IN = 'source-in',
4+
SOURCE_OUT = 'source-out',
5+
SOURCE_ATOP = 'source-atop',
6+
DESTINATION_OVER = 'destination-over',
7+
DESTINATION_IN = 'destination-in',
8+
DESTINATION_OUT = 'destination-out',
9+
DESTINATION_ATOP = 'destination-atop',
10+
LIGHTER = 'lighter',
11+
COPY = 'copy',
12+
XOR = 'xor',
13+
MULTIPLY = 'multiply',
14+
SCREEN = 'screen',
15+
OVERLAY = 'overlay',
16+
DARKEN = 'darken',
17+
LIGHTEN = 'lighten',
18+
COLOR_DODGE = 'color-dodge',
19+
COLOR_BURN = 'color-burn',
20+
HARD_LIGHT = 'hard-light',
21+
SOFT_LIGHT = 'soft-light',
22+
DIFFERENCE = 'difference',
23+
EXCLUSION = 'exclusion',
24+
HUE = 'hue',
25+
SATURATION = 'saturation',
26+
COLOR = 'color',
27+
LUMINOSITY = 'luminosity'
28+
}

src/Display/Bound.ts

+15-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
1-
import { Transform } from "Geom/Transform";
2-
import { Point } from "Geom/Point";
1+
import {Transform} from 'Geom/Transform'
2+
import {Point} from 'Geom/Point'
33

4-
export class Bound
5-
{
6-
private _transform:Transform;
7-
private _isAABBDirty:boolean;
4+
export class Bound {
5+
private _transform: Transform
6+
private _isAABBDirty: boolean
87

9-
private _vertices:Point[] =
10-
[
8+
private _vertices: Point[] = [
119
Point.ZERO,
1210
Point.ZERO,
1311
Point.ZERO,
1412
Point.ZERO
15-
];
13+
]
1614

17-
constructor(vertices:Point[])
18-
{
19-
this._transform = Transform.IDENTITY;
20-
this._vertices = vertices;
21-
this._isAABBDirty = true;
15+
constructor(vertices: Point[]) {
16+
this._transform = Transform.IDENTITY
17+
this._vertices = vertices
18+
this._isAABBDirty = true
2219
}
2320

24-
public static get IDENTITY():Bound
25-
{
26-
let vertices:Point[] = [
27-
Point.ZERO,
28-
Point.ZERO,
29-
Point.ONE,
30-
Point.ONE
31-
];
32-
return new Bound(vertices);
21+
public static get IDENTITY(): Bound {
22+
let vertices: Point[] = [Point.ZERO, Point.ZERO, Point.ONE, Point.ONE]
23+
return new Bound(vertices)
3324
}
34-
}
25+
}

src/Display/Color.ts

+48-46
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,66 @@
1-
export class Color
2-
{
3-
private _red:number;
4-
private _green:number;
5-
private _blue:number;
6-
private _alpha:number;
1+
export class Color {
2+
private _red: number
3+
private _green: number
4+
private _blue: number
5+
private _alpha: number
76

8-
constructor(red:number = 0, green:number = 0, blue:number = 0, alpha:number = 1)
9-
{
10-
this._red = red;
11-
this._green = green;
12-
this._blue = blue;
13-
this._alpha = alpha;
7+
constructor(
8+
red: number = 0,
9+
green: number = 0,
10+
blue: number = 0,
11+
alpha: number = 1
12+
) {
13+
this._red = red
14+
this._green = green
15+
this._blue = blue
16+
this._alpha = alpha
1417
}
1518

16-
public get red():number
17-
{
18-
return this._red;
19+
public get red(): number {
20+
return this._red
1921
}
2022

21-
public get green():number
22-
{
23-
return this._green;
23+
public get green(): number {
24+
return this._green
2425
}
2526

26-
public get blue():number
27-
{
28-
return this._blue;
27+
public get blue(): number {
28+
return this._blue
2929
}
3030

31-
public get alpha():number
32-
{
33-
return this._alpha;
31+
public get alpha(): number {
32+
return this._alpha
3433
}
3534

36-
public static get RED():Color
37-
{
38-
return new Color(1, 0, 0, 1);
35+
public static get RED(): Color {
36+
return new Color(1, 0, 0, 1)
3937
}
4038

41-
public toHexRGB():string
42-
{
43-
let red: number = Math.floor(this._red * 255);
44-
let green: number = Math.floor(this._green * 255);
45-
let blue: number = Math.floor(this._blue * 255);
39+
public toHexRGB(): string {
40+
let red: number = Math.floor(this._red * 255)
41+
let green: number = Math.floor(this._green * 255)
42+
let blue: number = Math.floor(this._blue * 255)
4643

47-
return "#" + red.toString(16).padStart(2, '0') +
48-
green.toString(16).padStart(2, '0') +
49-
blue.toString(16).padStart(2, '0');
44+
return (
45+
'#' +
46+
red.toString(16).padStart(2, '0') +
47+
green.toString(16).padStart(2, '0') +
48+
blue.toString(16).padStart(2, '0')
49+
)
5050
}
5151

52-
public toHexRGBA():string
53-
{
54-
let red: number = Math.floor(this._red * 255);
55-
let green: number = Math.floor(this._green * 255);
56-
let blue: number = Math.floor(this._blue * 255);
57-
let alpha: number = Math.floor(this._alpha * 255);
52+
public toHexRGBA(): string {
53+
let red: number = Math.floor(this._red * 255)
54+
let green: number = Math.floor(this._green * 255)
55+
let blue: number = Math.floor(this._blue * 255)
56+
let alpha: number = Math.floor(this._alpha * 255)
5857

59-
return "#" + red.toString(16).padStart(2, '0') +
60-
green.toString(16).padStart(2, '0') +
61-
blue.toString(16).padStart(2, '0') +
62-
alpha.toString(16).padStart(2, '0');
58+
return (
59+
'#' +
60+
red.toString(16).padStart(2, '0') +
61+
green.toString(16).padStart(2, '0') +
62+
blue.toString(16).padStart(2, '0') +
63+
alpha.toString(16).padStart(2, '0')
64+
)
6365
}
64-
}
66+
}

src/Display/Container.ts

+37-54
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,65 @@
1-
import { Spatial } from "./Spatial";
1+
import {Spatial} from './Spatial'
22

3-
export class Container extends Spatial
4-
{
5-
protected _children:Spatial[];
3+
export class Container extends Spatial {
4+
protected _children: Spatial[]
65

7-
constructor()
8-
{
9-
super();
10-
this._children = [];
6+
constructor() {
7+
super()
8+
this._children = []
119
}
1210

13-
public dispose()
14-
{
15-
this.removeAllChildren();
16-
super.dispose();
11+
public dispose() {
12+
this.removeAllChildren()
13+
super.dispose()
1714
}
1815

19-
public get children():Spatial[]
20-
{
21-
return this._children;
16+
public get children(): Spatial[] {
17+
return this._children
2218
}
2319

24-
public addChild(spatial:Spatial):void
25-
{
26-
if(this._children.lastIndexOf(spatial) != -1)
27-
{
20+
public addChild(spatial: Spatial): void {
21+
if (this._children.lastIndexOf(spatial) != -1) {
2822
//TODO warn
29-
return;
23+
return
3024
}
31-
spatial.parent = this;
32-
this._children.push(spatial);
25+
spatial.parent = this
26+
this._children.push(spatial)
3327
}
3428

35-
public removeChild(spatial:Spatial):void
36-
{
37-
let index = this._children.lastIndexOf(spatial);
38-
if(index != -1)
39-
{
40-
spatial.parent = null;
41-
this._children.splice(index, 1);
29+
public removeChild(spatial: Spatial): void {
30+
let index = this._children.lastIndexOf(spatial)
31+
if (index != -1) {
32+
spatial.parent = null
33+
this._children.splice(index, 1)
4234
}
4335
}
4436

45-
public removeAllChildren()
46-
{
47-
for(let child of this._children)
48-
{
49-
child.parent = null;
50-
child.dispose();
37+
public removeAllChildren() {
38+
for (let child of this._children) {
39+
child.parent = null
40+
child.dispose()
5141
}
52-
this._children = null;
42+
this._children = null
5343
}
5444

5545
// override
56-
public updateWorldData():void
57-
{
58-
super.updateWorldData();
46+
public updateWorldData(): void {
47+
super.updateWorldData()
5948

60-
for(let child of this._children)
61-
{
62-
child.update(false);
49+
for (let child of this._children) {
50+
child.update(false)
6351
}
6452
}
6553

66-
public draw():void
67-
{
68-
for(let child of this._children)
69-
{
70-
child.draw();
54+
public draw(): void {
55+
for (let child of this._children) {
56+
child.draw()
7157
}
7258
}
7359

74-
public drawDebug():void
75-
{
76-
for(let child of this._children)
77-
{
78-
child.drawDebug();
60+
public drawDebug(): void {
61+
for (let child of this._children) {
62+
child.drawDebug()
7963
}
8064
}
81-
82-
}
65+
}

0 commit comments

Comments
 (0)