Skip to content

Commit

Permalink
Configure eslint and standardize the stylequide all over the js examp…
Browse files Browse the repository at this point in the history
…les (mdn#1579)

* configure eslint

* fix eslint errors

* rename class

* add missing curly braces

* add missing empty line

* allow one line declaration in specific file

* allow missing block after for

* enforce eol as last character

* enforce template literals

* enforce no-var eslint rule

* enforce prefer-arrow-callback eslint rule

* enforce comma-spacing eslint rule

* enforce comma-style eslint rule

* enforce func-call-spacing eslint rule

* enforce key-spacing eslint rule

* enforce keyword-spacing eslint rule

* enforce no-multiple-empty-lines eslint rule

* enforce no-trailing-spaces eslint rule

* enforce space-before-function-paren eslint rule

* enforce indentation within switch statements

* enforce 1tbs brace-style with allowSingleLine option

* enforce no-array-constructor eslint rule

* enforce no-new-object eslint rule

* enforce space-infix-ops eslint rule

* enforce no-else-return eslint rule

* add styleguide check to travis

* add syntax highlight to the contributing md

* adjust styleguide in the contributing md

* remove osolated examples from the contribution guidelines

* remove unnecessary empty lines from contribution guidelines

* add override example to the contribution guidelines

* remove outdated styleguide hints
  • Loading branch information
ikarasz authored May 5, 2020
1 parent 8695185 commit 1d6085a
Show file tree
Hide file tree
Showing 129 changed files with 532 additions and 429 deletions.
302 changes: 272 additions & 30 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,291 @@ module.exports = {
env: {
browser: true,
es6: true,
jest: true,
node: true
node: true,
},
extends: 'eslint:recommended',
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 8
ecmaVersion: 6,
sourceType: 'script',
},
rules: {
'no-global-assign': 2,
indent: [2, 4],
'linebreak-style': [2, 'unix'],
quotes: [2, 'single'],
semi: [2, 'always'],
curly: [2, 'all'],
camelcase: [
2,
'brace-style': ['error', '1tbs', { 'allowSingleLine': true }],
'camelcase': [
'error',
{
properties: 'always'
}
properties: 'always',
},
],
eqeqeq: [2, 'smart'],
'comma-spacing': 'error',
'comma-style': 'error',
'curly': ['error', 'all'],
'eol-last': 'error',
'eqeqeq': ['error', 'smart'],
'func-call-spacing': 'error',
'new-cap': 'warn',
'no-array-constructor': 'error',
'no-console': [
'error',
{
allow: ['log', 'error']
allow: ['log', 'error'],
},
],
'no-new-object': 'error',
'indent': [
'error',
2,
{
'SwitchCase': 1,
}
],
'one-var-declaration-per-line': [2, 'always'],
'new-cap': 2
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': ['error', 'unix'],
'no-control-regex': 'error',
'no-else-return': 'error',
'no-global-assign': 'error',
'no-multiple-empty-lines': 'error',
'no-prototype-builtins': 'off',
'no-trailing-spaces': 'error',
'no-var': 'error',
'object-curly-spacing': ['error', 'always'],
'one-var-declaration-per-line': ['error', 'always'],
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
'quotes': ['error', 'single'],
'semi': ['error', 'always'],
'space-before-function-paren': ['error', 'never'],
'space-infix-ops': 'error',
},
globals: {
Clipboard: true,
CodeMirror: true,
console: true,
expect: true,
exports: true,
SharedArrayBuffer: true,
Atomics: true,
BigInt: true,
getShadowRoot: true,
module: true,
page: true,
Prism: true,
require: true,
ShadyCSS: true,
ShadyDOM: true,
test: true
}
globalThis: true, // will be supported in eslint 7.0
},
overrides: [
{
files: ['**/arraybuffer/arraybuffer-isview.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/expressions/expressions-comparisonoperators.js'],
rules: {
'eqeqeq': 'off',
},
},
{
files: ['**/expressions/expressions-destructuringassignment.js'],
rules: {
'one-var-declaration-per-line': 'off',
},
},
{
files: ['**/expressions/expressions-newtarget.js'],
rules: {
'new-cap': 'off',
},
},
{
files: ['**/expressions/expressions-operatorprecedence.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/expressions/expressions-voidoperator.js'],
rules: {
'no-undef': 'off',
},
},
{
files: ['**/function/function-length.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/functions/functions-arguments.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/map/map-prototype-foreach.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/object/object-prototype-isprototypeof.js'],
rules: {
'new-cap': 'off',
},
},
{
files: ['**/promise/promise-all.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/promise/promise-catch.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/promise/promise-constructor.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/promise/promise-race.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/promise/promise-reject.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/promise/promise-then.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/proxyhandler/proxyhandler-construct.js'],
rules: {
'new-cap': 'off',
},
},
{
files: ['**/proxyhandler/proxyhandler-defineproperty.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/proxyhandler/proxyhandler-get.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/proxyhandler/proxyhandler-getprototypeof.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/proxyhandler/proxyhandler-setprototypeof.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/reflect/reflect-construct.js'],
rules: {
'new-cap': 'off',
},
},
{
files: ['**/regexp/regexp-prototype-source.js'],
rules: {
'no-control-regex': 'off',
},
},
{
files: ['**/regexp/regexp-prototype-tostring.js'],
rules: {
'no-control-regex': 'off',
},
},
{
files: ['**/set/set-prototype-foreach.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/statement/statement-block.js'],
rules: {
'no-constant-condition': 'off',
'no-redeclare': 'off',
'no-unused-vars': 'off',
'no-var': 'off',
},
},
{
files: ['**/statement/statement-const.js'],
rules: {
'no-const-assign': 'off',
},
},
{
files: ['**/statement/statement-empty.js'],
rules: {
'curly': 'off',
},
},
{
files: ['**/statement/statement-trycatch.js'],
rules: {
'no-undef': 'off',
},
},
{
files: ['**/statement/statement-var.js'],
rules: {
'no-redeclare': 'off',
'no-var': 'off',
},
},
{
files: ['**/symbol/symbol-unscopables.js'],
rules: {
'no-with': 'off',
'no-undef': 'off',
},
},
{
files: ['**/typedarray/typedarray-every.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/typedarray/typedarray-filter.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/typedarray/typedarray-find.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/typedarray/typedarray-findindex.js'],
rules: {
'no-unused-vars': 'off',
},
},
{
files: ['**/typedarray/typedarray-some.js'],
rules: {
'no-unused-vars': 'off',
},
},
],
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ branches:
only:
- master
before_script:
- npm run lint:js
- npm run build
- sleep 3 # give build some time to complete
deploy:
Expand Down
Loading

0 comments on commit 1d6085a

Please sign in to comment.