Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(*): linting rules and fixes #233

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions .client.eslintrc.js

This file was deleted.

113 changes: 108 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,116 @@
const deprecatedUtilityClasses = require('./deprecated-utility-classes')

module.exports = {
root: true,
env: {
es2021: true,
},
globals: {
analytics: 'readonly',
konnect: 'readonly',
},
extends: [
'.client.eslintrc.js',
'plugin:portal-vue/all'
'plugin:vue/recommended',
'@vue/standard',
'@vue/typescript',
'plugin:portal-vue/all',
],
rules: {
'no-console': ['error', { allow: ['error'] }],
'vue/no-bare-strings-in-template': ['error'],
'arrow-parens': 'off',
'space-before-function-paren': 'off',
'generator-star-spacing': 'off',
'object-property-newline': 'error',
'lines-between-class-members': ['error', 'always'],
'padding-line-between-statements': [
'error',
{
blankLine: 'always',
prev: ['block', 'block-like'],
next: '*',
},
{
blankLine: 'always',
prev: '*',
next: 'return',
},
{
blankLine: 'always',
prev: ['const', 'let', 'var'],
next: '*',
},
{
blankLine: 'any',
prev: ['const', 'let', 'var'],
next: ['const', 'let', 'var', 'if'],
},
{
blankLine: 'always',
prev: 'directive',
next: '*',
},
{
blankLine: 'any',
prev: 'directive',
next: 'directive',
},
],
curly: 'error',
camelcase: 'off',
indent: 'off',
semi: ['error', 'never'],
quotes: ['error', 'single', {
avoidEscape: true,
}],
'comma-dangle': ['error', 'always-multiline'],
'eol-last': 'error',
'no-mixed-operators': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-unused-vars': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'@typescript-eslint/no-unused-vars': 'error',
'vue/custom-event-name-casing': 'off',
'vue/html-indent': 'error',
'array-bracket-spacing': ['error', 'never', {
singleValue: false,
objectsInArrays: false,
}],
'object-curly-spacing': ['error', 'always', {
arraysInObjects: true,
objectsInObjects: true,
}],
'@typescript-eslint/indent': ['error', 2],
'@typescript-eslint/space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
}],
'no-trailing-spaces': 'error',
'vue/multiline-html-element-content-newline': ['error', {
ignoreWhenEmpty: true,
ignores: ['CodeContent', 'pre', 'textarea', 'a'],
}],
'vue/attributes-order': ['error', {
alphabetical: true,
}],
'portal-vue/vue-setup-context': 'error',
'vue/multi-word-component-names': 'off',
// Disallow Kongponents utility classes
// TODO: Enable this rule when we remove all Kongponents utility classes
// 'vue/no-restricted-class': ['error', ...deprecatedUtilityClasses],
// Temporary rule that need to be resolved and turned back into errors
'vue/no-reserved-component-names': 'off'
}
'vue/no-reserved-component-names': 'off',
},
overrides: [
// TODO: Remove this override and enable the rule above when all directories remove all Kongponents utility classes
{
files: [
// TODO: Add directories here once the utility classes have been removed
'./src/fake-components/**/*', // TODO: This file array cannot be empty, so please replace with a valid path as you go
],
rules: {
'vue/no-restricted-class': ['error', ...deprecatedUtilityClasses],
},
},
],
}
4 changes: 3 additions & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
deploy:
# This permission is required on the first run of running the action on a branch
# because the branch doesn't exist the workflow needs permission to create it
permissions:
permissions:
contents: write
if: github.repository == 'kong/konnect-portal'
name: deploy build to github-pages
Expand All @@ -40,6 +40,8 @@ jobs:
echo "VITE_PORTAL_API_URL='https://api-konnect-portal.konghq.com/'" >> .env
echo "VITE_LOCALE='en'" >> .env
echo "VITE_ENABLE_LAUNCH_DARKLY=true" >> .env
- name: Stylelint
run: yarn stylelint
- name: Lint
run: yarn lint
- name: Build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
node-version-file: '.nvmrc'
- name: Install Dependencies
run: yarn install --frozen-lockfile
- name: Stylelint
run: yarn stylelint
- name: Lint
run: yarn lint
- name: Check TypeScript types
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
Expand Down
52 changes: 52 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Add allowed CSS custom property prefixes here as needed from the Appearance API
const allowedCssCustomPropertyPattern = '^(kui-|portal-ui-|font-|kong-ui-|text_colors-|button_colors-|section_colors-).+$'
const allowedCssCustomPropertyMessage = "Expected custom property \"%s\" to be sourced from @kong/design-tokens with prefix '--kui-' or to have one of the following prefixes: '--kong-ui-', '--text_colors', '--button_colors', '--section_colors', '--portal-ui', '--font'"

module.exports = {
extends: [
'stylelint-config-html',
'stylelint-config-recommended-scss',
'stylelint-config-recommended-vue/scss'
],
plugins: [
'stylelint-order',
'@kong/design-tokens/stylelint-plugin'
],
ignoreFiles: [
'cypress/**/*',
'dist/**/*',
],
rules: {
'order/properties-alphabetical-order': true,
'@kong/design-tokens/use-proper-token': true,
// Only allow @kong/design-tokens or `--kong-ui-*` CSS custom properties
'custom-property-pattern': [
allowedCssCustomPropertyPattern,
{
message: allowedCssCustomPropertyMessage,
severity: 'error'
}
],
'custom-property-no-missing-var-function': true,
// Disable the following rules
'no-descending-specificity': null,
},
overrides: [
// TODO: Remove this override and enable the rule above when all Kongponents utility classes and CSS custom properties have been removed
{
files: [
// TODO: Add directories here once the utility classes and CSS custom properties have been removed
// './src/components/ApiDocumentation/**/*',
],
rules: {
'custom-property-pattern': [
allowedCssCustomPropertyPattern,
{
message: allowedCssCustomPropertyMessage,
severity: 'error'
}
],
}
}
]
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"Vue.volar",
"Vue.vscode-typescript-vue-plugin",
"dbaeumer.vscode-eslint",
"stylelint.vscode-stylelint",
"mrmlnc.vscode-scss"
]
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// TODO: Re-enable before merge
// {
// "editor.codeActionsOnSave": {
// "source.fixAll.eslint": true,
// "source.fixAll.stylelint": true
// },
// "editor.formatOnPaste": true,
// "editor.trimAutoWhitespace": true,
// "editor.tabSize": 2,
// "editor.insertSpaces": true,
// "editor.detectIndentation": false,
// "eslint.format.enable": true,
// "eslint.validate": [
// "typescript",
// "javascript",
// "javascriptreact",
// "vue",
// "json"
// ],
// "scss.scannerExclude": [
// "**/.git",
// "**/bower_components"
// ]
// }
Loading
Loading