From e5977ec8499c16500e294708a6824a681429adf0 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Tue, 31 Aug 2021 18:25:49 +0300 Subject: [PATCH] web/: add custom linter for requiring @vue/component Also ignore coverage folder for linting. I had to add a new .stylelintignore file, because ignoreFiles property was not properly working. Change-Id: Iadd99b64eadd9c4103f750519263113ae8780ce1 --- web/eslint-storj/index.js | 46 ++ web/eslint-storj/package.json | 5 + web/multinode/.eslintrc.js | 5 + web/multinode/.stylelintignore | 11 + web/multinode/.stylelintrc.js | 1 - web/multinode/package-lock.json | 14 + web/multinode/package.json | 5 +- web/satellite/.eslintrc.js | 5 + web/satellite/.stylelintignore | 13 + web/satellite/.stylelintrc.js | 1 - web/satellite/package-lock.json | 13 + web/satellite/package.json | 5 +- web/satellite/src/views/ForgotPassword.vue | 716 ++++++++++----------- web/satellite/src/views/ResetPassword.vue | 688 ++++++++++---------- web/storagenode/.eslintrc.js | 5 + web/storagenode/.stylelintignore | 11 + web/storagenode/.stylelintrc.js | 1 - web/storagenode/package-lock.json | 13 + web/storagenode/package.json | 5 +- 19 files changed, 852 insertions(+), 711 deletions(-) create mode 100644 web/eslint-storj/index.js create mode 100644 web/eslint-storj/package.json create mode 100644 web/multinode/.stylelintignore create mode 100644 web/satellite/.stylelintignore create mode 100644 web/storagenode/.stylelintignore diff --git a/web/eslint-storj/index.js b/web/eslint-storj/index.js new file mode 100644 index 000000000..9604c4bf1 --- /dev/null +++ b/web/eslint-storj/index.js @@ -0,0 +1,46 @@ +// Copyright (C) 2021 Storj Labs, Inc. +// See LICENSE for copying information. + +module.exports = { + rules: { + "vue/require-annotation": { + meta: { + fixable: "code", + }, + create: function(context) { + return { + Decorator(node) { + let isComponent = false; + const expr = node.expression; + if(expr.name === "Component"){ + isComponent = true; + } else if (expr.callee && expr.callee.name === "Component"){ + isComponent = true; + } + if(!isComponent){ return; } + + const commentsBefore = context.getCommentsBefore(node); + const decoratorLine = node.loc.start.line; + let annotated = false; + commentsBefore.forEach(comment => { + if(comment.loc.start.line === decoratorLine - 1){ + if(comment.value.trim() === "@vue/component") { + annotated = true; + } + } + }) + if(!annotated){ + context.report({ + node: node, + message: '@Component requires // @vue/component', + fix: function(fixer) { + return fixer.insertTextBefore(node, "// @vue/component\n"); + } + }); + } + } + }; + } + } + } +}; \ No newline at end of file diff --git a/web/eslint-storj/package.json b/web/eslint-storj/package.json new file mode 100644 index 000000000..52f6dd5df --- /dev/null +++ b/web/eslint-storj/package.json @@ -0,0 +1,5 @@ +{ + "name": "eslint-plugin-storj", + "version": "1.0.0", + "main": "index.js" +} \ No newline at end of file diff --git a/web/multinode/.eslintrc.js b/web/multinode/.eslintrc.js index ca9f394f4..855b11f32 100644 --- a/web/multinode/.eslintrc.js +++ b/web/multinode/.eslintrc.js @@ -14,7 +14,10 @@ module.exports = { parserOptions: { ecmaVersion: 2020 }, + plugins: ["storj"], rules: { + "linebreak-style": ["error", "unix"], + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', @@ -41,5 +44,7 @@ module.exports = { "vue/no-useless-v-bind": ["warn"], 'vue/no-unregistered-components': ['warn', { ignorePatterns: ['router-link', 'router-view'] }], + + 'storj/vue/require-annotation': 'warn', }, } \ No newline at end of file diff --git a/web/multinode/.stylelintignore b/web/multinode/.stylelintignore new file mode 100644 index 000000000..bc13ac846 --- /dev/null +++ b/web/multinode/.stylelintignore @@ -0,0 +1,11 @@ +*.* +!*.vue +!*.css +!*.sss +!*.less +!*.scss +!*.sass + +dist +node_modules +coverage \ No newline at end of file diff --git a/web/multinode/.stylelintrc.js b/web/multinode/.stylelintrc.js index 439c217db..5754ac064 100644 --- a/web/multinode/.stylelintrc.js +++ b/web/multinode/.stylelintrc.js @@ -11,7 +11,6 @@ module.exports = { "stylelint-scss" ], "extends": "stylelint-config-standard", - "ignoreFiles": ["dist/**"], "rules": { "indentation": 4, "string-quotes": "single", diff --git a/web/multinode/package-lock.json b/web/multinode/package-lock.json index 5d53f2b45..e8da1a7c9 100644 --- a/web/multinode/package-lock.json +++ b/web/multinode/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "multinode", "version": "0.0.1", "dependencies": { "chart.js": "2.9.4", @@ -33,6 +34,7 @@ "compression-webpack-plugin": "6.0.0", "core-js": "3.6.5", "eslint": "6.7.2", + "eslint-plugin-storj": "file:../eslint-storj", "eslint-plugin-vue": "7.16.0", "jest-fetch-mock": "3.0.0", "sass": "1.37.0", @@ -49,6 +51,11 @@ "vue-template-compiler": "2.6.11" } }, + "../eslint-storj": { + "name": "eslint-plugin-storj", + "version": "1.0.0", + "dev": true + }, "node_modules/@babel/code-frame": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", @@ -10722,6 +10729,10 @@ "rimraf": "bin.js" } }, + "node_modules/eslint-plugin-storj": { + "resolved": "../eslint-storj", + "link": true + }, "node_modules/eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", @@ -36217,6 +36228,9 @@ } } }, + "eslint-plugin-storj": { + "version": "file:../eslint-storj" + }, "eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", diff --git a/web/multinode/package.json b/web/multinode/package.json index 1437210df..891c1702d 100644 --- a/web/multinode/package.json +++ b/web/multinode/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "lint": "vue-cli-service lint --max-warnings 0 --fix && stylelint --max-warnings 0 \"**/*.{vue,css,sss,less,scss,sass}\" --fix", - "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint --max-warnings 0 --no-fix \"**/*.{vue,css,sss,less,scss,sass}\"", + "lint": "vue-cli-service lint --max-warnings 0 --fix && stylelint . --max-warnings 0 --fix", + "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint . --max-warnings 0 --no-fix", "build": "vue-cli-service build", "dev": "vue-cli-service build --mode development --watch", "test": "vue-cli-service test:unit" @@ -38,6 +38,7 @@ "core-js": "3.6.5", "eslint": "6.7.2", "eslint-plugin-vue": "7.16.0", + "eslint-plugin-storj": "file:../eslint-storj", "jest-fetch-mock": "3.0.0", "sass": "1.37.0", "sass-loader": "8.0.0", diff --git a/web/satellite/.eslintrc.js b/web/satellite/.eslintrc.js index ca9f394f4..855b11f32 100644 --- a/web/satellite/.eslintrc.js +++ b/web/satellite/.eslintrc.js @@ -14,7 +14,10 @@ module.exports = { parserOptions: { ecmaVersion: 2020 }, + plugins: ["storj"], rules: { + "linebreak-style": ["error", "unix"], + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', @@ -41,5 +44,7 @@ module.exports = { "vue/no-useless-v-bind": ["warn"], 'vue/no-unregistered-components': ['warn', { ignorePatterns: ['router-link', 'router-view'] }], + + 'storj/vue/require-annotation': 'warn', }, } \ No newline at end of file diff --git a/web/satellite/.stylelintignore b/web/satellite/.stylelintignore new file mode 100644 index 000000000..c8d5f2fd2 --- /dev/null +++ b/web/satellite/.stylelintignore @@ -0,0 +1,13 @@ +*.* +!*.vue +!*.css +!*.sss +!*.less +!*.scss +!*.sass + +dist +node_modules +coverage +Dockerfile +entrypoint \ No newline at end of file diff --git a/web/satellite/.stylelintrc.js b/web/satellite/.stylelintrc.js index 439c217db..5754ac064 100644 --- a/web/satellite/.stylelintrc.js +++ b/web/satellite/.stylelintrc.js @@ -11,7 +11,6 @@ module.exports = { "stylelint-scss" ], "extends": "stylelint-config-standard", - "ignoreFiles": ["dist/**"], "rules": { "indentation": 4, "string-quotes": "single", diff --git a/web/satellite/package-lock.json b/web/satellite/package-lock.json index bbafa234e..f6aeed284 100644 --- a/web/satellite/package-lock.json +++ b/web/satellite/package-lock.json @@ -52,6 +52,7 @@ "babel-eslint": "10.1.0", "compression-webpack-plugin": "6.0.0", "eslint": "6.7.2", + "eslint-plugin-storj": "file:../eslint-storj", "eslint-plugin-vue": "7.16.0", "jest-fetch-mock": "3.0.3", "sass": "1.37.0", @@ -68,6 +69,11 @@ "worker-plugin": "5.0.0" } }, + "../eslint-storj": { + "name": "eslint-plugin-storj", + "version": "1.0.0", + "dev": true + }, "node_modules/@babel/code-frame": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", @@ -11802,6 +11808,10 @@ "rimraf": "bin.js" } }, + "node_modules/eslint-plugin-storj": { + "resolved": "../eslint-storj", + "link": true + }, "node_modules/eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", @@ -39522,6 +39532,9 @@ } } }, + "eslint-plugin-storj": { + "version": "file:../eslint-storj" + }, "eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", diff --git a/web/satellite/package.json b/web/satellite/package.json index f27eea67d..dbf243324 100644 --- a/web/satellite/package.json +++ b/web/satellite/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "lint": "vue-cli-service lint --max-warnings 0 && stylelint --max-warnings 0 \"**/*.{vue,css,sss,less,scss,sass}\" --fix", - "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint --max-warnings 0 --no-fix \"**/*.{vue,css,sss,less,scss,sass}\"", + "lint": "vue-cli-service lint --max-warnings 0 --fix && stylelint . --max-warnings 0 --fix", + "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint . --max-warnings 0 --no-fix", "build": "vue-cli-service build", "wasm": "chmod +x ./scripts/build-wasm.sh && ./scripts/build-wasm.sh", "dev": "vue-cli-service build --mode development --watch", @@ -57,6 +57,7 @@ "compression-webpack-plugin": "6.0.0", "eslint": "6.7.2", "eslint-plugin-vue": "7.16.0", + "eslint-plugin-storj": "file:../eslint-storj", "jest-fetch-mock": "3.0.3", "sass": "1.37.0", "sass-loader": "10.0.2", diff --git a/web/satellite/src/views/ForgotPassword.vue b/web/satellite/src/views/ForgotPassword.vue index b28650108..78e106959 100644 --- a/web/satellite/src/views/ForgotPassword.vue +++ b/web/satellite/src/views/ForgotPassword.vue @@ -1,358 +1,358 @@ -// Copyright (C) 2021 Storj Labs, Inc. -// See LICENSE for copying information. - - - - - - +// Copyright (C) 2021 Storj Labs, Inc. +// See LICENSE for copying information. + + + + + + diff --git a/web/satellite/src/views/ResetPassword.vue b/web/satellite/src/views/ResetPassword.vue index 5f135c392..b96b7fc5c 100644 --- a/web/satellite/src/views/ResetPassword.vue +++ b/web/satellite/src/views/ResetPassword.vue @@ -1,344 +1,344 @@ -// Copyright (C) 2021 Storj Labs, Inc. -// See LICENSE for copying information. - - - - - - +// Copyright (C) 2021 Storj Labs, Inc. +// See LICENSE for copying information. + + + + + + diff --git a/web/storagenode/.eslintrc.js b/web/storagenode/.eslintrc.js index b55681163..dfb2350ae 100644 --- a/web/storagenode/.eslintrc.js +++ b/web/storagenode/.eslintrc.js @@ -14,7 +14,10 @@ module.exports = { parserOptions: { ecmaVersion: 2020 }, + plugins: ["storj"], rules: { + "linebreak-style": ["error", "unix"], + 'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', 'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', @@ -43,5 +46,7 @@ module.exports = { "vue/no-useless-v-bind": ["warn"], 'vue/no-unregistered-components': ['warn', { ignorePatterns: ['router-link', 'router-view'] }], + + 'storj/vue/require-annotation': 'warn', }, } \ No newline at end of file diff --git a/web/storagenode/.stylelintignore b/web/storagenode/.stylelintignore new file mode 100644 index 000000000..bc13ac846 --- /dev/null +++ b/web/storagenode/.stylelintignore @@ -0,0 +1,11 @@ +*.* +!*.vue +!*.css +!*.sss +!*.less +!*.scss +!*.sass + +dist +node_modules +coverage \ No newline at end of file diff --git a/web/storagenode/.stylelintrc.js b/web/storagenode/.stylelintrc.js index 4b57ecf0c..0171a813f 100644 --- a/web/storagenode/.stylelintrc.js +++ b/web/storagenode/.stylelintrc.js @@ -11,7 +11,6 @@ module.exports = { "stylelint-scss" ], "extends": "stylelint-config-standard", - "ignoreFiles": ["dist/**"], "rules": { "indentation": 4, "string-quotes": "single", diff --git a/web/storagenode/package-lock.json b/web/storagenode/package-lock.json index e2f40a77b..e06b0f063 100644 --- a/web/storagenode/package-lock.json +++ b/web/storagenode/package-lock.json @@ -35,6 +35,7 @@ "compression-webpack-plugin": "6.0.0", "core-js": "3.6.5", "eslint": "6.7.2", + "eslint-plugin-storj": "file:../eslint-storj", "eslint-plugin-vue": "7.16.0", "jest-fetch-mock": "3.0.0", "sass": "1.37.0", @@ -51,6 +52,11 @@ "vue-template-compiler": "2.6.11" } }, + "../eslint-storj": { + "name": "eslint-plugin-storj", + "version": "1.0.0", + "dev": true + }, "node_modules/@babel/code-frame": { "version": "7.14.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", @@ -10730,6 +10736,10 @@ "rimraf": "bin.js" } }, + "node_modules/eslint-plugin-storj": { + "resolved": "../eslint-storj", + "link": true + }, "node_modules/eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", @@ -36231,6 +36241,9 @@ } } }, + "eslint-plugin-storj": { + "version": "file:../eslint-storj" + }, "eslint-plugin-vue": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-7.16.0.tgz", diff --git a/web/storagenode/package.json b/web/storagenode/package.json index a0421fe29..7ce26a40a 100644 --- a/web/storagenode/package.json +++ b/web/storagenode/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "lint": "vue-cli-service lint --max-warnings 0 --fix && stylelint --max-warnings 0 \"**/*.{vue,css,sss,less,scss,sass}\" --fix", - "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint --max-warnings 0 --no-fix \"**/*.{vue,css,sss,less,scss,sass}\"", + "lint": "vue-cli-service lint --max-warnings 0 --fix && stylelint . --max-warnings 0 --fix", + "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint . --max-warnings 0 --no-fix", "build": "vue-cli-service build", "dev": "vue-cli-service build --mode development --watch", "test": "vue-cli-service test:unit" @@ -39,6 +39,7 @@ "core-js": "3.6.5", "eslint": "6.7.2", "eslint-plugin-vue": "7.16.0", + "eslint-plugin-storj": "file:../eslint-storj", "jest-fetch-mock": "3.0.0", "sass": "1.37.0", "sass-loader": "8.0.0",