mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Introduce eslint and prettier for features and start using it (#7306)
* Introduce package for sharing eslint and prettier configurations Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Start using eslint and prettier in packages Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> --------- Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
2789bcebcb
commit
699fc0309e
36 files changed
+2973
-610
No files matched your search
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: "@k8slens/eslint-config/eslint",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
"@k8slens/eslint-config/prettier"
|
||||
@@ -1,2 +1 @@
|
||||
module.exports =
|
||||
require("@k8slens/jest").monorepoPackageConfig(__dirname).configForNode;
|
||||
module.exports = require("@k8slens/jest").monorepoPackageConfig(__dirname).configForNode;
|
||||
@@ -26,7 +26,9 @@
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"dev": "webpack --mode=development --watch",
|
||||
"test": "jest --coverage --runInBand"
|
||||
"test": "jest --coverage --runInBand",
|
||||
"lint": "lens-lint",
|
||||
"lint:fix": "lens-lint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
@@ -37,6 +39,7 @@
|
||||
},
|
||||
|
||||
"devDependencies": {
|
||||
"@async-fn/jest": "^1.6.4"
|
||||
"@async-fn/jest": "^1.6.4",
|
||||
"@k8slens/eslint-config": "*"
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -10,15 +10,15 @@ export type ApplicationInformation = {
|
||||
productName: string;
|
||||
copyright: string;
|
||||
description: string;
|
||||
k8sProxyVersion: string,
|
||||
bundledKubectlVersion: string,
|
||||
bundledHelmVersion: string,
|
||||
sentryDsn: string,
|
||||
contentSecurityPolicy: string,
|
||||
welcomeRoute: string,
|
||||
k8sProxyVersion: string;
|
||||
bundledKubectlVersion: string;
|
||||
bundledHelmVersion: string;
|
||||
sentryDsn: string;
|
||||
contentSecurityPolicy: string;
|
||||
welcomeRoute: string;
|
||||
updatingIsEnabled: boolean;
|
||||
dependencies: Partial<Record<string, string>>;
|
||||
}
|
||||
};
|
||||
|
||||
export const applicationInformationToken = getInjectionToken<ApplicationInformation>({
|
||||
id: "application-information-token",
|
||||
|
||||
@@ -9,9 +9,7 @@ export const applicationFeature = getFeature({
|
||||
di,
|
||||
targetModule: module,
|
||||
|
||||
getRequireContexts: () => [
|
||||
require.context("./", true, /\.injectable\.(ts|tsx)$/),
|
||||
],
|
||||
getRequireContexts: () => [require.context("./", true, /\.injectable\.(ts|tsx)$/)],
|
||||
});
|
||||
},
|
||||
});
|
||||
+3
-7
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
createContainer,
|
||||
DiContainer,
|
||||
getInjectable,
|
||||
} from "@ogre-tools/injectable";
|
||||
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { applicationFeature } from "../feature";
|
||||
import { startApplicationInjectionToken } from "./start-application.injectable";
|
||||
@@ -46,7 +42,7 @@ describe("starting-of-application", () => {
|
||||
di.register(
|
||||
beforeApplicationIsLoadingInjectable,
|
||||
onLoadOfApplicationInjectable,
|
||||
afterApplicationIsLoadedInjectable
|
||||
afterApplicationIsLoadedInjectable,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -54,7 +50,7 @@ describe("starting-of-application", () => {
|
||||
beforeEach(() => {
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
startApplication();
|
||||
void startApplication();
|
||||
});
|
||||
|
||||
it("calls runnables registered in before application is loading", () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"extends": "@k8slens/typescript/config/base.json"
|
||||
"extends": "@k8slens/typescript/config/base.json",
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: "@k8slens/eslint-config/eslint",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
"@k8slens/eslint-config/prettier"
|
||||
@@ -4,4 +4,4 @@ export * from "./src/start-application/time-slots";
|
||||
|
||||
export { applicationFeatureForElectronMain } from "./src/feature";
|
||||
|
||||
export const testUtils = { overrideSideEffectsWithFakes }
|
||||
export const testUtils = { overrideSideEffectsWithFakes };
|
||||
@@ -1,2 +1 @@
|
||||
module.exports =
|
||||
require("@k8slens/jest").monorepoPackageConfig(__dirname).configForNode;
|
||||
module.exports = require("@k8slens/jest").monorepoPackageConfig(__dirname).configForNode;
|
||||
@@ -26,7 +26,9 @@
|
||||
"scripts": {
|
||||
"build": "webpack",
|
||||
"dev": "webpack --mode=development --watch",
|
||||
"test": "jest --coverage --runInBand"
|
||||
"test": "jest --coverage --runInBand",
|
||||
"lint": "lens-lint",
|
||||
"lint:fix": "lens-lint --fix"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@k8slens/feature-core": "^6.5.0-alpha.0",
|
||||
@@ -38,6 +40,7 @@
|
||||
|
||||
"devDependencies": {
|
||||
"@async-fn/jest": "^1.6.4",
|
||||
"@ogre-tools/test-utils": "^15.1.2"
|
||||
"@ogre-tools/test-utils": "^15.1.2",
|
||||
"@k8slens/eslint-config": "*"
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,14 +1,14 @@
|
||||
import electronAppInjectable from "./electron-app.injectable";
|
||||
import { app } from 'electron';
|
||||
import { app } from "electron";
|
||||
import { createContainer } from "@ogre-tools/injectable";
|
||||
import { applicationFeatureForElectronMain } from "../feature";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
|
||||
describe('electron-app', () => {
|
||||
it('is electron app', () => {
|
||||
const di = createContainer('irrelevant');
|
||||
describe("electron-app", () => {
|
||||
it("is electron app", () => {
|
||||
const di = createContainer("irrelevant");
|
||||
|
||||
registerFeature(di, applicationFeatureForElectronMain)
|
||||
registerFeature(di, applicationFeatureForElectronMain);
|
||||
|
||||
const actual = di.inject(electronAppInjectable);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getFeature } from "@k8slens/feature-core";
|
||||
import { autoRegister } from "@ogre-tools/injectable-extension-for-auto-registration";
|
||||
import { applicationFeature } from '@k8slens/application';
|
||||
import { applicationFeature } from "@k8slens/application";
|
||||
|
||||
export const applicationFeatureForElectronMain = getFeature({
|
||||
id: "application-for-electron-main",
|
||||
@@ -10,13 +10,9 @@ export const applicationFeatureForElectronMain = getFeature({
|
||||
di,
|
||||
targetModule: module,
|
||||
|
||||
getRequireContexts: () => [
|
||||
require.context("./", true, /\.injectable\.(ts|tsx)$/),
|
||||
],
|
||||
getRequireContexts: () => [require.context("./", true, /\.injectable\.(ts|tsx)$/)],
|
||||
});
|
||||
},
|
||||
|
||||
dependencies: [
|
||||
applicationFeature
|
||||
]
|
||||
dependencies: [applicationFeature],
|
||||
});
|
||||
+1
-1
@@ -2,5 +2,5 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import whenAppIsReadyInjectable from "./start-application/when-app-is-ready.injectable";
|
||||
|
||||
export const overrideSideEffectsWithFakes = (di: DiContainer) => {
|
||||
di.override(whenAppIsReadyInjectable, () => () => Promise.resolve())
|
||||
di.override(whenAppIsReadyInjectable, () => () => Promise.resolve());
|
||||
};
|
||||
+1
-4
@@ -18,10 +18,7 @@ describe("when-app-is-ready", () => {
|
||||
|
||||
whenReadyMock = asyncFn();
|
||||
|
||||
di.override(
|
||||
electronAppInjectable,
|
||||
() => ({ whenReady: whenReadyMock } as unknown)
|
||||
);
|
||||
di.override(electronAppInjectable, () => ({ whenReady: whenReadyMock } as unknown));
|
||||
});
|
||||
|
||||
describe("when called", () => {
|
||||
|
||||
+3
-7
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
createContainer,
|
||||
DiContainer,
|
||||
getInjectable,
|
||||
} from "@ogre-tools/injectable";
|
||||
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
|
||||
import { registerFeature } from "@k8slens/feature-core";
|
||||
import { applicationFeatureForElectronMain } from "./feature";
|
||||
import {
|
||||
@@ -52,7 +48,7 @@ describe("starting-of-electron-main-application", () => {
|
||||
di.register(
|
||||
beforeAnythingIsLoadingInjectable,
|
||||
beforeElectronIsReadyIsLoadingInjectable,
|
||||
beforeApplicationIsLoadingInjectable
|
||||
beforeApplicationIsLoadingInjectable,
|
||||
);
|
||||
|
||||
di.override(whenAppIsReadyInjectable, () => whenAppIsReadyMock);
|
||||
@@ -62,7 +58,7 @@ describe("starting-of-electron-main-application", () => {
|
||||
beforeEach(() => {
|
||||
const startApplication = di.inject(startApplicationInjectionToken);
|
||||
|
||||
startApplication();
|
||||
void startApplication();
|
||||
});
|
||||
|
||||
it("calls for synchronous runnables for before anything", () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"extends": "@k8slens/typescript/config/base.json"
|
||||
"extends": "@k8slens/typescript/config/base.json",
|
||||
"include": ["**/*.ts"]
|
||||
}
|
||||
Reference in new issue
Block a user