Skip to content

Commit

Permalink
chore: bump eslint-plugin-sonarjs to version 1.0.3 and use this in es…
Browse files Browse the repository at this point in the history
…lint
  • Loading branch information
tzuyi0817 committed May 17, 2024
1 parent 9ca40ff commit b4e2f98
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const configPrettier = require('eslint-config-prettier');
const pluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
const pluginSecurity = require('eslint-plugin-security');
const pluginNext = require('@next/eslint-plugin-next');
const pluginSonarjs = require('eslint-plugin-sonarjs');
const globals = require('globals');

const nextConfig = {
Expand All @@ -22,7 +23,7 @@ module.exports = [
...tsEslint.configs.recommended,
configPrettier,
pluginPrettierRecommended,
// 'plugin:sonarjs/recommended',
pluginSonarjs.configs.recommended,
pluginSecurity.configs.recommended,
nextConfig,
{ files: ['**/*.js', '**/*./ts', '**/*./txs'] },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-security": "^3.0.0",
"eslint-plugin-sonarjs": "^0.25.0",
"eslint-plugin-sonarjs": "^1.0.3",
"globals": "^15.0.0",
"postcss": "8.4.38",
"postcss-nesting": "^12.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/mind-mapping/configs/command.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const COMMANDS = ['INSERT_NODE', 'REMOVE_NODE'];
export const COMMANDS = ['INSERT_NODE', 'INSERT_CHILD_NODE', 'REMOVE_NODE'];
5 changes: 5 additions & 0 deletions packages/mind-mapping/core/renderer/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ class RendererCommand {
}
bindEvents() {
this.insertNode = this.insertNode.bind(this);
this.insertChildNode = this.insertChildNode.bind(this);
this.removeNode = this.removeNode.bind(this);
}
registerCommand() {
this.command.add('INSERT_NODE', this.insertNode);
this.command.add('INSERT_CHILD_NODE', this.insertChildNode);
this.command.add('REMOVE_NODE', this.removeNode);
}
insertNode(specifyNodes: MindNode[] = []) {
Expand Down Expand Up @@ -47,6 +49,9 @@ class RendererCommand {
this.renderer.clearActiveNodes();
this.renderer.render();
}
insertChildNode(specifyNodes: MindNode[] = []) {
console.log(specifyNodes, 'insertChildNode');
}
removeNode(specifyNodes: MindNode[] = []) {
if (!this.renderer.activeNodes.size && !specifyNodes.length) return;
const nodes = specifyNodes.length ? specifyNodes : [...this.renderer.activeNodes];
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions website/components/canvas/toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ function Toolbar() {
};
}, []);

function handleInsertNode() {
instance.current?.command.execute('INSERT_NODE');
}

function handleRemoveNode() {
instance.current?.command.execute('REMOVE_NODE');
function sendCommand(command: string) {
instance.current?.command.execute(command);
}

return (
Expand All @@ -41,15 +37,21 @@ function Toolbar() {
<IconButton icon="GitCommit">格式化</IconButton>
<IconButton
icon="GitBranchPlus"
onClick={handleInsertNode}
onClick={() => sendCommand('INSERT_NODE')}
disabled={!isSelected}
>
插入同級節點
</IconButton>
<IconButton icon="GitPullRequest">插入子節點</IconButton>
<IconButton
icon="GitPullRequest"
onClick={() => sendCommand('INSERT_CHILD_NODE')}
disabled={!isSelected}
>
插入子節點
</IconButton>
<IconButton
icon="Trash2"
onClick={handleRemoveNode}
onClick={() => sendCommand('REMOVE_NODE')}
disabled={!isSelected}
>
刪除節點
Expand Down

0 comments on commit b4e2f98

Please sign in to comment.