Template
fix: make template build, lint and test cleanly out of the box
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"settings": {
|
||||
"import/resolver": {
|
||||
"typescript": {
|
||||
"project": "./tsconfig.json"
|
||||
}
|
||||
},
|
||||
"react": {
|
||||
"version": "17.0.2"
|
||||
}
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:react-hooks/recommended",
|
||||
"plugin:import/recommended",
|
||||
"plugin:import/typescript"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"plugins": [
|
||||
"react",
|
||||
"import",
|
||||
"@typescript-eslint",
|
||||
"unused-imports"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"jsx": true,
|
||||
"impliedStrict": true,
|
||||
"modules": true,
|
||||
"experimentalObjectRestSpread": true
|
||||
}
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"jquery": false,
|
||||
"es6": true
|
||||
},
|
||||
"rules": {
|
||||
"no-unused-vars": "warn",
|
||||
"no-unused-expressions": "warn",
|
||||
"unused-imports/no-unused-imports": "warn",
|
||||
"import/no-named-as-default": "off"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import js from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
import unusedImports from 'eslint-plugin-unused-imports';
|
||||
|
||||
export default tseslint.config(
|
||||
{ ignores: ['dist/', 'node_modules/', 'src/manifest.ts'] },
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
'react-hooks': reactHooks,
|
||||
'unused-imports': unusedImports,
|
||||
},
|
||||
rules: {
|
||||
...reactHooks.configs.recommended.rules,
|
||||
'unused-imports/no-unused-imports': 'warn',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
'@typescript-eslint/ban-ts-comment': 'off',
|
||||
// В шаблоне пустые типы — заготовки, которые вы заполните
|
||||
'@typescript-eslint/no-empty-object-type': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
+8
-4
@@ -6,10 +6,14 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"build:watch": "vite build --watch",
|
||||
"debug": "vite build --minify false --sourcemap inline",
|
||||
"debug:watch": "vite build --minify false --sourcemap inline --watch",
|
||||
"dev": "vite",
|
||||
"lint": "eslint --ignore-pattern node_modules --ignore-pattern dist --ext .js --ext .jsx --ext tsx --ext ts . --quiet --cache",
|
||||
"fix": "eslint --ignore-pattern node_modules --ignore-pattern dist --ext .js --ext .jsx --ext tsx --ext ts . --quiet --fix --cache",
|
||||
"check-types": "tsc"
|
||||
"lint": "eslint . --quiet --cache",
|
||||
"fix": "eslint . --quiet --fix --cache",
|
||||
"check-types": "tsc",
|
||||
"test": "echo \"no webapp tests\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/plugin-transform-modules-umd": "^7.27.1",
|
||||
@@ -33,7 +37,7 @@
|
||||
"eslint": "^9.26.0",
|
||||
"eslint-plugin-import": "2.22.0",
|
||||
"eslint-plugin-react": "7.20.3",
|
||||
"eslint-plugin-react-hooks": "4.0.6",
|
||||
"eslint-plugin-react-hooks": "5.2.0",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"file-loader": "6.0.0",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
import React from "react";
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { Provider } from 'react-redux';
|
||||
import manifest from '../manifest';
|
||||
import usePlugin from '../utils/usePlugin';
|
||||
import React from 'react';
|
||||
|
||||
// Корневой компонент всегда присутствует на странице, но ничего не показывает сам по себе.
|
||||
// Держите здесь то, что должно работать постоянно: модальные окна, фоновую логику.
|
||||
// Доступ к объекту плагина — хук usePlugin() из ../utils/usePlugin.
|
||||
const RootComponent: React.FC = () => {
|
||||
const dispatch = useDispatch();
|
||||
const plugin = usePlugin();
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Add your root component content here */}
|
||||
<p>Template Plugin Root Component</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default RootComponent
|
||||
export default RootComponent;
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import { getPluginAssetsPath } from '../utils/utils';
|
||||
|
||||
export const basePath = getPluginAssetsPath();
|
||||
|
||||
// Add your assets configuration here
|
||||
export type AssetsType = {
|
||||
// Define your asset types
|
||||
}
|
||||
|
||||
const assets: AssetsType = {
|
||||
// Add your assets here
|
||||
} as const
|
||||
|
||||
export default assets
|
||||
@@ -1,5 +0,0 @@
|
||||
import Svgs from './svgs.js';
|
||||
|
||||
export {
|
||||
Svgs,
|
||||
};
|
||||
@@ -25,7 +25,7 @@ function pluginState(state: PluginStore = EmptyState, { type, data }: ActionType
|
||||
case ACTIONS.EXAMPLE_ACTION:
|
||||
return {
|
||||
...state,
|
||||
// Handle action
|
||||
...data,
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
// trackEvent: (event: Telemetry.Event, source: Telemetry.Source, props?: Record<string, string>) => void,
|
||||
@@ -1,18 +0,0 @@
|
||||
import { getTheme } from 'loop-plugin-sdk/loop/redux/selectors/entities/preferences';
|
||||
import { GlobalState } from 'loop-plugin-sdk/loop/types/store';
|
||||
import React, { useEffect } from "react";
|
||||
import { useSelector } from 'react-redux';
|
||||
import { isDarkTheme } from './colorUtils';
|
||||
|
||||
const useIsDarkTheme = () => {
|
||||
const [isDark, setIsDark] = React.useState(false);
|
||||
const theme = useSelector((state: GlobalState) => getTheme(state))
|
||||
|
||||
useEffect(() => {
|
||||
setIsDark(isDarkTheme());
|
||||
}, [theme])
|
||||
|
||||
return isDark
|
||||
}
|
||||
|
||||
export default useIsDarkTheme
|
||||
+6
-6
@@ -3117,12 +3117,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"eslint-plugin-react-hooks@npm:4.0.6":
|
||||
version: 4.0.6
|
||||
resolution: "eslint-plugin-react-hooks@npm:4.0.6"
|
||||
"eslint-plugin-react-hooks@npm:5.2.0":
|
||||
version: 5.2.0
|
||||
resolution: "eslint-plugin-react-hooks@npm:5.2.0"
|
||||
peerDependencies:
|
||||
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
|
||||
checksum: 10c0/bc261eb7b2ac177c86f397e65f556c0f1273fcb96ee07155e2611716fa0b6c9e687c99fa91925421c11ebb4b769c8b78624bb9c86ecf68a353297f17212f5697
|
||||
eslint: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0
|
||||
checksum: 10c0/1c8d50fa5984c6dea32470651807d2922cc3934cf3425e78f84a24c2dfd972e7f019bee84aefb27e0cf2c13fea0ac1d4473267727408feeb1c56333ca1489385
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5824,7 +5824,7 @@ __metadata:
|
||||
eslint: "npm:^9.26.0"
|
||||
eslint-plugin-import: "npm:2.22.0"
|
||||
eslint-plugin-react: "npm:7.20.3"
|
||||
eslint-plugin-react-hooks: "npm:4.0.6"
|
||||
eslint-plugin-react-hooks: "npm:5.2.0"
|
||||
eslint-plugin-unused-imports: "npm:^4.1.4"
|
||||
file-loader: "npm:6.0.0"
|
||||
identity-obj-proxy: "npm:3.0.0"
|
||||
|
||||
Reference in New Issue
Block a user