Commit eb0047ea authored by René Dudfield's avatar René Dudfield
Browse files

plugins: Add "npm run lint" so plugins are lint free

parent 11e6275c
main a11y-reporting action-button-improvements add-cluster-to-notification-area add-clusters-dynamically add-direct-c-o-c add-fullscreen-to-editor add-labs add-more-log-options add-msi-installer add-network-policy-api add-notification-area add-notification-page add-ports-to-pods add-proxy-endpoint add-router-to-pluginLib add_manual_trigger_docker_action allow-listing-per-namespace allow-popups-in-app allow-to-build-without-checking-for-updates app-menus apply-multiple-resources autoscalers_resource_quota backend-dependencies branding-change build-app-with-plugins bump-chocolatey-0.13.0 center-cluster-chooser change-logo chart-0.10.1 choco-bump-0.12.1 cluster_chooser codegen config_from_env custom-resource-fixing de-de dep-updates2 dependabot/npm_and_yarn/app/electron-13.6.6 dependabot/npm_and_yarn/app/electron-15.5.5 dependabot/npm_and_yarn/app/minimist-1.2.6 dependabot/npm_and_yarn/frontend/async-2.6.4 dependabot/npm_and_yarn/frontend/d3-color-and-recharts-3.1.0 dependabot/npm_and_yarn/frontend/deep-object-diff-1.1.9 dependabot/npm_and_yarn/frontend/loader-utils-1.4.2 dependabot/npm_and_yarn/frontend/minimist-1.2.6 dependabot/npm_and_yarn/frontend/terser-4.8.1 dependabot/npm_and_yarn/frontend/url-parse-1.5.10 dependabot/npm_and_yarn/plugins/examples/app-menus/terser-5.14.2 dependabot/npm_and_yarn/plugins/examples/change-logo/glob-parent-and-kinvolk/headlamp-plugin-5.1.2 dependabot/npm_and_yarn/plugins/examples/change-logo/terser-5.14.2 dependabot/npm_and_yarn/plugins/examples/cluster-chooser/glob-parent-and-kinvolk/headlamp-plugin-5.1.2 dependabot/npm_and_yarn/plugins/examples/cluster-chooser/terser-5.14.2 dependabot/npm_and_yarn/plugins/examples/dynamic-clusters/glob-parent-and-kinvolk/headlamp-plugin-5.1.2 dependabot/npm_and_yarn/plugins/examples/dynamic-clusters/terser-5.14.2 dependabot/npm_and_yarn/plugins/examples/sidebar/terser-5.14.2 dependabot/npm_and_yarn/plugins/headlamp-plugin/async-3.2.3 dependabot/npm_and_yarn/plugins/headlamp-plugin/minimist-1.2.6 dependabot/npm_and_yarn/plugins/headlamp-plugin/terser-5.14.2 docker_desktop_ext docs-allow-to-build-without-checking-for-updates dont-cache-plugin-requests-on-desktop dont-use-a-one-click-installer-on-windows dont-wrap-header-cells e2e-container e2e-login e2e-playwright endpoints errcb-fix event-sorting example-fixes export-charts export-resource-chart-and-lib export_all_k8s_modules fetch-pods-by-labels fix-applying-ingresses fix-cluster-chooser fix-crash-in-label-selector fix-default-page-rows fix-filter-when-items-are-numbers fix-front-start fix-issue-in-page-grid-children-type fix-kubeconfig fix-navigating-during-delete-op fix-plugin-imports-again fix-quitting-server-again fix-release-note-stuck-issue fix-simple-table fix-table-filter fix-unexpected-null-in-getOwnedPods fix_manual_trigger_gh_action fr-fr fullscreen_dialog gh_action_automate_pr go-back-through-location-stack golang-17 handle-custom-auth-desktop headlamp-plugin-0.5.1-b headlamp-plugin-0.5.2-b headlamp-plugin-upgrade headlamp-upgrade-audit headless-fix headless-ux helm-fixes helm-typo-docs-fix hide-appbar improve-app-menus improve-pod-matcher improve-pod-status inno-setup jrocha/wip/show-build-version localefix log-viewer-scroll-fix mui-v5-upgrade namespaces-filter new-chooser-style new-k8s-secret new-terminal-fixes no-cluster-no-auth-required no-objects-in-plugins-redux notification-clear-and-all-read oidc-fix oidc-state-len-fix optimize-use-get persist-rows-per-page persist-url-params plugin-docs plugin-error-handling plugin-fixes plugin-improvements plugin-source plugin-tests-in-js plugin/allow-cluster-chooser-overriding plugins-in-style port-forwarding push-asset rc-0.10.0 rc-0.10.1 rc-0.11.0 rc-0.11.1 rc-0.12.0 rc-0.12.1 rc-0.13.0 rc-0.8.0 rc-0.9.0 redux-extension refresh_token remove-plugin-video rename-server render-logs-using-xterm resource-class-issue resources-json role_bind_info scaling-ui search-involved-object-type-events-table set-default-namespace shorter-resource-age show-build-version show-dialog-if-release-fetch-failed show-external-ips sidebar-icons sidebarroutefilter simple-table-details-from-url simplify-testing terminal-fixes test-cleanup test-stuff typedoc-plugin-upgrade update-examples-052 update-i18n update-release-draft update-signing-email upgrade-new-things use-fixed-date-on-tests use-shipped-tsconfig-for-plugins wait-for-plugins width-cosmetic-fixes windows-testing xterm-windows-mode v0.13.0 v0.12.1 v0.12.0 v0.11.1 v0.11.0 v0.10.1 v0.10.0 v0.9.0 v0.8.0 headlamp-plugin-0.5.3 headlamp-plugin-0.5.2 headlamp-plugin-0.5.1 headlamp-plugin-0.5.0 headlamp-plugin-0.4.9 headlamp-plugin-0.4.8 headlamp-plugin-0.4.7 headlamp-helm-0.8.0 headlamp-helm-0.7.0 headlamp-helm-0.6.0 headlamp-helm-0.5.0 headlamp-helm-0.4.0 headlamp-helm-0.3.0 headlamp-helm-0.2.0
No related merge requests found
Showing with 96 additions and 197 deletions
+96 -197
......@@ -70,7 +70,7 @@
"build": "if-env PUBLIC_URL react-scripts build || cross-env PUBLIC_URL=./ react-scripts build --max_old_space_size=768 && rimraf build/frontend/index.baseUrl.html",
"test": "cross-env TEST_TZ=true react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint -c package.json --ext .js,.ts,.tsx src/ ../app/electron ../plugins/headlamp-plugin",
"lint": "eslint -c package.json --ext .js,.ts,.tsx src/ ../app/electron ../plugins/headlamp-plugin --ignore-pattern ../plugins/headlamp-plugin/template",
"format": "prettier --config package.json --write src ../app/electron ../plugins/headlamp-plugin/bin ../plugins/headlamp-plugin/lib ../plugins/headlamp-plugin/config",
"format-check": "prettier --config package.json --check src ../app/electron ../plugins/headlamp-plugin",
"storybook": "start-storybook -p 6006 -s public",
......
......@@ -316,6 +316,27 @@ function format(packageFolder) {
return 0;
}
/**
* Lint code with eslint.
*
* @param packageFolder {string} - folder where the package is.
* @returns {0 | 1} Exit code, where 0 is success, 1 is failure.
*/
function lint(packageFolder) {
try {
child_process.execSync('eslint -c package.json --ext .js,.ts,.tsx src/', {
stdio: 'inherit',
cwd: packageFolder,
encoding: 'utf8',
});
} catch (e) {
console.error(`Problem running prettier inside of "${packageFolder}"`);
return 1;
}
return 0;
}
yargs(process.argv.slice(2))
.command(
'build [package]',
......@@ -390,6 +411,21 @@ yargs(process.argv.slice(2))
process.exitCode = format(argv.package);
}
)
.command(
'lint [package]',
'Lint the plugin for coding issues with eslint. ' +
'<package> defaults to current working directory.',
yargs => {
yargs.positional('package', {
describe: 'Package to lint',
type: 'string',
default: '.',
});
},
argv => {
process.exitCode = lint(argv.package);
}
)
.demandCommand(1, '')
.strict()
.help().argv;
This diff is collapsed.
......@@ -21,6 +21,14 @@
"babel-loader": "^8.1.0",
"env-paths": "^2.2.1",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.22.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-unused-imports": "^1.1.2",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"filemanager-webpack-plugin": "^4.0.0",
"fs-extra": "^9.1.0",
"imports-loader": "^1.1.0",
......
......@@ -6,6 +6,7 @@
"start": "headlamp-plugin start",
"build": "headlamp-plugin build",
"format": "headlamp-plugin format",
"lint": "headlamp-plugin lint",
"tsc": "tsc"
},
"keywords": [
......@@ -15,6 +16,13 @@
"plugins"
],
"prettier": "@kinvolk/eslint-config/prettier-config",
"eslintConfig": {
"extends": [
"@kinvolk",
"prettier",
"plugin:jsx-a11y/recommended"
]
},
"devDependencies": {
"@kinvolk/headlamp-plugin": "^$${headlamp-plugin-version}"
}
......
......@@ -46,3 +46,6 @@ node bin/headlamp-plugin.js create headlamp-myfancy --link
cd headlamp-myfancy
npm install ../kinvolk-headlamp-plugin-*.tgz
npm run format
# test lint command and default code is lint free
npm run lint
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment