-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve linting to check for ES5 conformance (with exceptions to allo…
…w use of ES6 classes in certain modules) (#5342) * Switch semistandard to standardx * Running with latest semistandard * Tighten exceptions for use of `class` as tightly as possible * Alphabetize exceptions * Enforce computed-property-spacing rule * Enforce "no-multiple-empty-lines" rule * Enforce "no-unused-expressions" rule * Enforce 'no-use-before-define' rule * Enforce 'object-curly-newline' rule * Enforce 'quotes' rule * Enforce 'spaced-comment' rule * Enforce 'valid-typeof' rule * Add comments explaining unenforced rules * Apply 'array-bracket-spacing' rule * Final comments on unused linting rules from semistandard v17 * More comments to explain config * PR review feedback * PR feedback Previous attempt didn't preserve this in forEach() callback. This version should work better (while still only using ES5 constructs). * Correct merge issue from rebase; linting issues.
- Loading branch information
1 parent
7d33792
commit 2c97ce9
Showing
27 changed files
with
103 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"extends": ["semistandard", "standard-jsx"], | ||
"parserOptions": { | ||
"ecmaVersion": 12 | ||
}, | ||
"rules": { | ||
/* These rules are incompatible with ES5. */ | ||
"no-var": "off", | ||
"object-shorthand": "off", | ||
"prefer-const": "off", | ||
"prefer-regex-literals": "off", | ||
|
||
/* These rules are compatible with ES5 | ||
However they involve non-trivial code changes | ||
Therefore need more careful review before adopting. */ | ||
"array-callback-return": "off", | ||
"no-mixed-operators": "off", | ||
"no-unreachable-loop": "off", | ||
"no-useless-return": "off", | ||
"prefer-promise-reject-errors": "off", | ||
|
||
/* These rules are compatible with ES5 | ||
However they involve large-scale changes to the codebase, so | ||
careful co-ordination is needed in adopting the rule to avoid | ||
creating merge issues for other PRs. */ | ||
"dot-notation": "off", | ||
"indent": "off", | ||
"no-multi-spaces": "off", | ||
"no-unused-vars": "off", | ||
"object-curly-spacing": "off", | ||
"quote-props": "off" | ||
}, | ||
"overrides": [ | ||
{ | ||
/* Code within /src is restricted to using ES5 JavaScript | ||
The exception is that ES6 classes are used sparingly - see exceptions below. */ | ||
"files": ["./src/**/*.js"], | ||
|
||
"parserOptions": { | ||
"sourceType": "script", | ||
"ecmaVersion": 5 | ||
} | ||
}, | ||
{ | ||
/* These modules use ES6 classes, and so are parsed as ES6 to avoid errors. */ | ||
"files": ["./src/core/**/a-*.js"], | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
} | ||
}, | ||
{ | ||
/* This module use ES6 classes, and so is parsed as ES6 to avoid errors. */ | ||
"files": ["./src/extras/primitives/primitives.js"], | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
} | ||
}, | ||
{ | ||
/* This code is external, and the ES5 restrictions do not apply to it. */ | ||
"files": ["./src/lib/**/*.js"], | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": 12 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -369,4 +369,4 @@ | |
|
||
/***/ }) | ||
/******/ ]); | ||
/*eslint-enable */ | ||
/* eslint-enable */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,3 @@ class ACubeMap extends HTMLElement { | |
} | ||
|
||
customElements.define('a-cubemap', ACubeMap); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,3 @@ module.exports.Shader = registerShader('ios10hls', { | |
'}' | ||
].join('\n') | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,3 @@ module.exports.Shader = registerShader('shadow', { | |
this.material.transparent = data.transparent; | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,4 +97,3 @@ suite('tracked-controls-webxr', function () { | |
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,4 +73,3 @@ suite('tracked-controls-webxr', function () { | |
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,3 @@ suite('tracked-controls', function () { | |
assert.notOk(el.components['tracked-controls-webxr']); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,4 +218,3 @@ suite('a-mixin (detached)', function () { | |
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters