From abc7cc9a263a28f5ba643e4dbb60a246f4453678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 19 Aug 2019 19:20:55 +0200 Subject: [PATCH] lint: Convert eslint JSON to YAML gjs has changed its configuration to YAML, so switch to that format to keep syncing possible. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/818 --- .eslintrc.json | 6 -- .eslintrc.yml | 3 + .gitlab-ci/run-eslint.sh | 2 +- lint/eslintrc-gjs.json | 130 -------------------------------------- lint/eslintrc-gjs.yml | 88 ++++++++++++++++++++++++++ lint/eslintrc-legacy.json | 19 ------ lint/eslintrc-legacy.yml | 13 ++++ lint/eslintrc-shell.json | 46 -------------- lint/eslintrc-shell.yml | 31 +++++++++ 9 files changed, 136 insertions(+), 202 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 .eslintrc.yml delete mode 100644 lint/eslintrc-gjs.json create mode 100644 lint/eslintrc-gjs.yml delete mode 100644 lint/eslintrc-legacy.json create mode 100644 lint/eslintrc-legacy.yml delete mode 100644 lint/eslintrc-shell.json create mode 100644 lint/eslintrc-shell.yml diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 30afb5924..000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": [ - "./lint/eslintrc-gjs.json", - "./lint/eslintrc-shell.json" - ] -} diff --git a/.eslintrc.yml b/.eslintrc.yml new file mode 100644 index 000000000..5e3347d3a --- /dev/null +++ b/.eslintrc.yml @@ -0,0 +1,3 @@ +extends: + - ./lint/eslintrc-gjs.yml + - ./lint/eslintrc-shell.yml diff --git a/.gitlab-ci/run-eslint.sh b/.gitlab-ci/run-eslint.sh index 103ba9361..8b1f8c1a9 100755 --- a/.gitlab-ci/run-eslint.sh +++ b/.gitlab-ci/run-eslint.sh @@ -13,7 +13,7 @@ is_empty() { } run_eslint() { - ARGS_LEGACY='--config lint/eslintrc-legacy.json' + ARGS_LEGACY='--config lint/eslintrc-legacy.yml' local extra_args=ARGS_$1 local output_var=OUTPUT_$1 diff --git a/lint/eslintrc-gjs.json b/lint/eslintrc-gjs.json deleted file mode 100644 index 74cadf263..000000000 --- a/lint/eslintrc-gjs.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "env": { - "es6": true - }, - "extends": "eslint:recommended", - "rules": { - "array-bracket-newline": [ - "error", - "consistent" - ], - "array-bracket-spacing": [ - "error", - "never" - ], - "arrow-spacing": "error", - "brace-style": "error", - "comma-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "indent": [ - "error", - 4, - { - "ignoredNodes": [ - "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" - ], - "MemberExpression": "off" - } - ], - "key-spacing": [ - "error", - { - "beforeColon": false, - "afterColon": true - } - ], - "keyword-spacing": [ - "error", - { - "before": true, - "after": true - } - ], - "linebreak-style": [ - "error", - "unix" - ], - "no-empty": [ - "error", - { - "allowEmptyCatch": true - } - ], - "no-implicit-coercion": [ - "error", - { - "allow": ["!!"] - } - ], - "no-restricted-properties": [ - "error", - { - "object": "Lang", - "property": "bind", - "message": "Use arrow notation or Function.prototype.bind()" - }, - { - "object": "Lang", - "property": "Class", - "message": "Use ES6 classes" - } - ], - "nonblock-statement-body-position": [ - "error", - "below" - ], - "object-curly-newline": [ - "error", - { - "consistent": true - } - ], - "object-curly-spacing": "error", - "prefer-template": "error", - "quotes": [ - "error", - "single", - { - "avoidEscape": true - } - ], - "semi": [ - "error", - "always" - ], - "semi-spacing": [ - "error", - { - "before": false, - "after": true - } - ], - "space-before-blocks": "error", - "space-infix-ops": [ - "error", - { - "int32Hint": false - } - ] - }, - "globals": { - "ARGV": false, - "Debugger": false, - "GIRepositoryGType": false, - "imports": false, - "Intl": false, - "log": false, - "logError": false, - "print": false, - "printerr": false, - "window": false - }, - "parserOptions": { - "ecmaVersion": 2017 - } -} diff --git a/lint/eslintrc-gjs.yml b/lint/eslintrc-gjs.yml new file mode 100644 index 000000000..50da632db --- /dev/null +++ b/lint/eslintrc-gjs.yml @@ -0,0 +1,88 @@ +--- +env: + es6: true +extends: 'eslint:recommended' +rules: + array-bracket-newline: + - error + - consistent + array-bracket-spacing: + - error + - never + arrow-spacing: error + brace-style: error + comma-spacing: + - error + - before: false + after: true + indent: + - error + - 4 + - ignoredNodes: + # Allow not indenting the body of GObject.registerClass, since in the + # future it's intended to be a decorator + - 'CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child' + # Allow dedenting chained member expressions + MemberExpression: 'off' + key-spacing: + - error + - beforeColon: false + afterColon: true + keyword-spacing: + - error + - before: true + after: true + linebreak-style: + - error + - unix + no-empty: + - error + - allowEmptyCatch: true + no-implicit-coercion: + - error + - allow: + - '!!' + no-restricted-properties: + - error + - object: Lang + property: bind + message: Use arrow notation or Function.prototype.bind() + - object: Lang + property: Class + message: Use ES6 classes + nonblock-statement-body-position: + - error + - below + object-curly-newline: + - error + - consistent: true + object-curly-spacing: error + prefer-template: error + quotes: + - error + - single + - avoidEscape: true + semi: + - error + - always + semi-spacing: + - error + - before: false + after: true + space-before-blocks: error + space-infix-ops: + - error + - int32Hint: false +globals: + ARGV: readonly + Debugger: readonly + GIRepositoryGType: readonly + imports: readonly + Intl: readonly + log: readonly + logError: readonly + print: readonly + printerr: readonly + window: readonly +parserOptions: + ecmaVersion: 2017 diff --git a/lint/eslintrc-legacy.json b/lint/eslintrc-legacy.json deleted file mode 100644 index e49d5c63a..000000000 --- a/lint/eslintrc-legacy.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "rules": { - "indent": [ - "error", - 4, - { - "ignoredNodes": [ - "CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child" - ], - "CallExpression": { "arguments": "first" }, - "ArrayExpression": "first", - "ObjectExpression": "first", - "MemberExpression": "off" - } - ], - "prefer-template": "off", - "quotes": "off" - } -} diff --git a/lint/eslintrc-legacy.yml b/lint/eslintrc-legacy.yml new file mode 100644 index 000000000..b67f914f9 --- /dev/null +++ b/lint/eslintrc-legacy.yml @@ -0,0 +1,13 @@ +rules: + indent: + - error + - 4 + - ignoredNodes: + - 'CallExpression[callee.object.name=GObject][callee.property.name=registerClass] > ClassExpression:first-child' + CallExpression: + arguments: first + ArrayExpression: first + ObjectExpression: first + MemberExpression: off + prefer-template: off + quotes: off diff --git a/lint/eslintrc-shell.json b/lint/eslintrc-shell.json deleted file mode 100644 index 1cae2f4e7..000000000 --- a/lint/eslintrc-shell.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "rules": { - "camelcase": [ - "error", - { - "properties": "never", - "allow": ["^vfunc_", "^on_"] - } - ], - "consistent-return": "error", - "key-spacing": [ - "error", - { - "mode": "minimum", - "beforeColon": false, - "afterColon": true - } - ], - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "_$" - } - ], - "object-curly-spacing": [ - "error", - "always" - ], - "prefer-arrow-callback": "error" - }, - - "overrides": [ - { - "files": "js/**", - "excludedFiles": ["js/extensionPrefs/*", "js/portalHelper/*"], - "globals": { - "global": false, - "_": false, - "C_": false, - "N_": false, - "ngettext": false - } - } - ] -} diff --git a/lint/eslintrc-shell.yml b/lint/eslintrc-shell.yml new file mode 100644 index 000000000..302dbca3e --- /dev/null +++ b/lint/eslintrc-shell.yml @@ -0,0 +1,31 @@ +rules: + camelcase: + - error + - properties: never + allow: [^vfunc_, ^on_] + consistent-return: error + key-spacing: + - error + - mode: minimum + beforeColon: false + afterColon: true + no-unused-vars: + - error + - argsIgnorePattern: ^_ + varsIgnorePattern: _$ + object-curly-spacing: + - error + - always + prefer-arrow-callback: error + +overrides: + - files: js/** + excludedFiles: + - js/extensionPrefs/* + - js/portalHelper/* + globals: + global: readonly + _: readonly + C_: readonly + N_: readonly + ngettext: readonly