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
This commit is contained in:
Egon Elbre 2021-08-31 18:25:49 +03:00
parent ee4361fe0d
commit e5977ec849
19 changed files with 852 additions and 711 deletions

46
web/eslint-storj/index.js Normal file
View File

@ -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");
}
});
}
}
};
}
}
}
};

View File

@ -0,0 +1,5 @@
{
"name": "eslint-plugin-storj",
"version": "1.0.0",
"main": "index.js"
}

View File

@ -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',
},
}

View File

@ -0,0 +1,11 @@
*.*
!*.vue
!*.css
!*.sss
!*.less
!*.scss
!*.sass
dist
node_modules
coverage

View File

@ -11,7 +11,6 @@ module.exports = {
"stylelint-scss"
],
"extends": "stylelint-config-standard",
"ignoreFiles": ["dist/**"],
"rules": {
"indentation": 4,
"string-quotes": "single",

View File

@ -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",

View File

@ -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",

View File

@ -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',
},
}

View File

@ -0,0 +1,13 @@
*.*
!*.vue
!*.css
!*.sss
!*.less
!*.scss
!*.sass
dist
node_modules
coverage
Dockerfile
entrypoint

View File

@ -11,7 +11,6 @@ module.exports = {
"stylelint-scss"
],
"extends": "stylelint-config-standard",
"ignoreFiles": ["dist/**"],
"rules": {
"indentation": 4,
"string-quotes": "single",

View File

@ -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",

View File

@ -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",

View File

@ -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',
},
}

View File

@ -0,0 +1,11 @@
*.*
!*.vue
!*.css
!*.sss
!*.less
!*.scss
!*.sass
dist
node_modules
coverage

View File

@ -11,7 +11,6 @@ module.exports = {
"stylelint-scss"
],
"extends": "stylelint-config-standard",
"ignoreFiles": ["dist/**"],
"rules": {
"indentation": 4,
"string-quotes": "single",

View File

@ -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",

View File

@ -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",