1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

lint whole repo (#1600)

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2020-12-02 04:22:10 -05:00 committed by GitHub
parent dcf253e7d5
commit f3f9f08c0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 110 additions and 105 deletions

View File

@ -4,6 +4,7 @@ module.exports = {
ignorePatterns: [
"**/node_modules/**/*",
"**/dist/**/*",
"**/static/**/*",
],
settings: {
react: {

View File

@ -1,5 +1,5 @@
{
"name": "extension-example",
"name": "example-extension",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,

View File

@ -37,7 +37,7 @@
"download:kubectl": "yarn run ts-node build/download_kubectl.ts",
"download:helm": "yarn run ts-node build/download_helm.ts",
"build:tray-icons": "yarn run ts-node build/build_tray_icon.ts",
"lint": "yarn run eslint $@ --ext js,ts,tsx --max-warnings=0 src/ integration/ __mocks__/ build/ extensions/",
"lint": "yarn run eslint $@ --ext js,ts,tsx --max-warnings=0 .",
"lint:fix": "yarn run lint --fix",
"mkdocs-serve-local": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-serve-local:latest",
"verify-docs": "docker build -t mkdocs-serve-local:latest mkdocs/ && docker run --rm -v ${PWD}:/docs mkdocs-serve-local:latest build --strict",

4
types/dom.d.ts vendored
View File

@ -1,7 +1,7 @@
export {}
export {};
declare global {
interface Element {
scrollIntoViewIfNeeded(opt_center?: boolean): void;
}
}
}

12
types/font-face.d.ts vendored
View File

@ -1,6 +1,6 @@
// https://www.w3.org/TR/css-font-loading/
// https://developer.mozilla.org/en-US/docs/Web/API/FontFace
export {}
export {};
declare global {
const FontFace: FontFace;
@ -10,11 +10,11 @@ declare global {
}
type CSSOMString = string;
type FontFaceLoadStatus = 'unloaded' | 'loading' | 'loaded' | 'error';
type FontFaceSetStatus = 'loading' | 'loaded';
type FontFaceLoadStatus = "unloaded" | "loading" | "loaded" | "error";
type FontFaceSetStatus = "loading" | "loaded";
interface FontFace extends FontFaceDescriptors {
new(family: string, source: string | ArrayBuffer, descriptors?: FontFaceDescriptors): FontFace;
class FontFace implements FontFaceDescriptors {
constructor(family: string, source: string | ArrayBuffer, descriptors?: FontFaceDescriptors);
readonly status: FontFaceLoadStatus;
readonly loaded: Promise<FontFace>;
variationSettings: CSSOMString;
@ -41,4 +41,4 @@ declare global {
delete(font: FontFace): void;
clear(): void;
}
}
}

View File

@ -1,87 +1,89 @@
import path from 'path';
import path from "path";
import webpack from "webpack";
import { sassCommonVars } from "./src/common/vars";
export default function (): webpack.Configuration {
const entry = "./src/extensions/extension-api.ts"
const outDir = "./src/extensions/npm/extensions/dist";
return {
// Compile for Electron for renderer process
// see <https://webpack.js.org/configuration/target/>
target: "electron-renderer",
entry,
output: {
filename: 'extension-api.js',
// need to be an absolute path
path: path.resolve(__dirname, `${outDir}/src/extensions`),
// can be use in commonjs environments
// e.g. require('@k8slens/extensions')
libraryTarget: "commonjs"
const entry = "./src/extensions/extension-api.ts";
const outDir = "./src/extensions/npm/extensions/dist";
return {
// Compile for Electron for renderer process
// see <https://webpack.js.org/configuration/target/>
target: "electron-renderer",
entry,
// this is the default mode, so we should make it explicit to silence the warning
mode: "production",
output: {
filename: "extension-api.js",
// need to be an absolute path
path: path.resolve(__dirname, `${outDir}/src/extensions`),
// can be use in commonjs environments
// e.g. require('@k8slens/extensions')
libraryTarget: "commonjs"
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: {
// !! ts-loader will use tsconfig.json at folder root
// !! changes in tsconfig.json may have side effects
// !! on '@k8slens/extensions' module
compilerOptions: {
declaration: true, // output .d.ts
sourceMap: false, // to override sourceMap: true in tsconfig.json
outDir // where the .d.ts should be located
}
}
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
// !! ts-loader will use tsconfig.json at folder root
// !! changes in tsconfig.json may have side effects
// !! on '@k8slens/extensions' module
compilerOptions: {
declaration: true, // output .d.ts
sourceMap: false, // to override sourceMap: true in tsconfig.json
outDir // where the .d.ts should be located
}
}
// for src/renderer/components/fonts/roboto-mono-nerd.ttf
// in src/renderer/components/dock/terminal.ts 95:25-65
{
test: /\.(ttf|eot|woff2?)$/,
use: {
loader: "url-loader",
options: {
name: "fonts/[name].[ext]"
}
}
},
// for import scss files
{
test: /\.s?css$/,
use: [
// creates `style` nodes from JS strings
"style-loader",
// translates CSS into CommonJS
"css-loader",
{
loader: "sass-loader",
options: {
prependData: `@import "${path.basename(sassCommonVars)}";`,
sassOptions: {
includePaths: [
path.dirname(sassCommonVars)
]
},
// for src/renderer/components/fonts/roboto-mono-nerd.ttf
// in src/renderer/components/dock/terminal.ts 95:25-65
{
test: /\.(ttf|eot|woff2?)$/,
use: {
loader: "url-loader",
options: {
name: "fonts/[name].[ext]"
}
}
},
// for import scss files
{
test: /\.s?css$/,
use: [
// creates `style` nodes from JS strings
"style-loader",
// translates CSS into CommonJS
"css-loader",
{
loader: "sass-loader",
options: {
prependData: `@import "${path.basename(sassCommonVars)}";`,
sassOptions: {
includePaths: [
path.dirname(sassCommonVars)
]
},
}
},
]
}
]
},
resolve: {
extensions: ['.ts', '.tsx', '.js']
},
plugins: [
// In ts-loader's README they said to output a built .d.ts file,
// you can set "declaration": true in tsconfig.extensions.json,
// and use the DeclarationBundlerPlugin in your webpack config... but
// !! the DeclarationBundlerPlugin doesn't work anymore, author archived it.
// https://www.npmjs.com/package/declaration-bundler-webpack-plugin
// new DeclarationBundlerPlugin({
// moduleName: '@k8slens/extensions',
// out: 'extension-api.d.ts',
// })
]
};
}
},
]
}
]
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
plugins: [
// In ts-loader's README they said to output a built .d.ts file,
// you can set "declaration": true in tsconfig.extensions.json,
// and use the DeclarationBundlerPlugin in your webpack config... but
// !! the DeclarationBundlerPlugin doesn't work anymore, author archived it.
// https://www.npmjs.com/package/declaration-bundler-webpack-plugin
// new DeclarationBundlerPlugin({
// moduleName: '@k8slens/extensions',
// out: 'extension-api.d.ts',
// })
]
};
}

View File

@ -1,12 +1,13 @@
import path from "path";
import webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { isDevelopment, isProduction, mainDir, buildDir } from "./src/common/vars";
import nodeExternals from "webpack-node-externals";
import ProgressBarPlugin from "progress-bar-webpack-plugin";
import * as vars from "./src/common/vars";
export default function (): webpack.Configuration {
console.info('WEBPACK:main', require("./src/common/vars"))
console.info("WEBPACK:main", vars);
return {
context: __dirname,
target: "electron-main",
@ -21,7 +22,7 @@ export default function (): webpack.Configuration {
path: buildDir,
},
resolve: {
extensions: ['.json', '.js', '.ts']
extensions: [".json", ".js", ".ts"]
},
externals: [
nodeExternals()
@ -48,5 +49,5 @@ export default function (): webpack.Configuration {
new ProgressBarPlugin(),
new ForkTsCheckerPlugin(),
].filter(Boolean)
}
};
}

View File

@ -4,17 +4,18 @@ import webpack from "webpack";
import HtmlWebpackPlugin from "html-webpack-plugin";
import MiniCssExtractPlugin from "mini-css-extract-plugin";
import TerserPlugin from "terser-webpack-plugin";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import ProgressBarPlugin from "progress-bar-webpack-plugin";
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
import * as vars from "./src/common/vars";
export default [
webpackLensRenderer
]
];
export function webpackLensRenderer({ showVars = true } = {}): webpack.Configuration {
if (showVars) {
console.info('WEBPACK:renderer', require("./src/common/vars"));
console.info("WEBPACK:renderer", vars);
}
return {
context: __dirname,
@ -27,7 +28,7 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
hot: true,
// to avoid cors errors when requests is from iframes
disableHostCheck: true,
headers: { 'Access-Control-Allow-Origin': '*' },
headers: { "Access-Control-Allow-Origin": "*" },
},
name: "lens-app",
mode: isProduction ? "production" : "development",
@ -39,10 +40,10 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
libraryTarget: "global",
library: "",
globalObject: "this",
publicPath: publicPath,
publicPath,
path: buildDir,
filename: '[name].js',
chunkFilename: 'chunks/[name].js',
filename: "[name].js",
chunkFilename: "chunks/[name].js",
},
stats: {
warningsFilter: [
@ -51,8 +52,8 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
},
resolve: {
extensions: [
'.js', '.jsx', '.json',
'.ts', '.tsx',
".js", ".jsx", ".json",
".ts", ".tsx",
]
},
optimization: {
@ -91,7 +92,7 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
}],
],
plugins: [
isDevelopment && require.resolve('react-refresh/babel'),
isDevelopment && require.resolve("react-refresh/babel"),
].filter(Boolean),
}
},
@ -190,5 +191,5 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
isDevelopment && new ReactRefreshWebpackPlugin(),
].filter(Boolean),
}
};
}