Skip to content

Commit

Permalink
lint is perfomed from the root of the project
Browse files Browse the repository at this point in the history
Unify eslint & tsconfig
  • Loading branch information
kaisalmen committed Nov 7, 2023
1 parent 5c4476b commit 4787ce3
Show file tree
Hide file tree
Showing 31 changed files with 325 additions and 314 deletions.
115 changes: 111 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,116 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['./configs/.eslintrc.js'],
ignorePatterns: ['**/{node_modules,lib}'],
env: {
browser: true,
node: true
},
extends: [
'prettier'
],
parser: '@typescript-eslint/parser',
ignorePatterns: [
'**/{node_modules,lib}',
'**/sprotty-local-template/**/*'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: 'tsconfig.json'
project: './tsconfig.json'
},
plugins: [
'eslint-plugin-no-null',
'@typescript-eslint',
'header'
],
rules: {
'@typescript-eslint/indent': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-shadow': [
'warn',
{
'hoist': 'all'
}
],
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/semi': [
'error',
'always'
],
'@typescript-eslint/type-annotation-spacing': 'warn',
'header/header': ['error', 'block', [{'pattern': '[\n\r]+ \\* Copyright \\([cC]\\) \\d{4}(-\\d{4})? .*[\n\r]+'}]],
'brace-style': [
'warn',
'1tbs',
{ 'allowSingleLine': true }
],
'comma-dangle': ['warn', {
'arrays': 'only-multiline',
'objects': 'only-multiline',
}],
'constructor-super': 'error',
'curly': 'off',
'eol-last': 'warn',
'eqeqeq': [
'warn',
'smart'
],
'guard-for-in': 'warn',
'id-blacklist': 'off',
'id-match': 'off',
'keyword-spacing': ['warn', { 'before': true }],
'max-len': [
'warn',
{
'code': 180
}
],
'no-prototype-builtins': 'error',
'no-caller': 'error',
'no-console': 'off',
'no-debugger': 'warn',
'no-eval': 'error',
'no-fallthrough': 'warn',
'no-invalid-this': 'warn',
'no-new-wrappers': 'warn',
'no-null/no-null': 'off',
'no-redeclare': 'off',
'no-restricted-imports': [
'error',
'..',
'../index',
'../..',
'../../index'
],
'no-return-await': 'warn',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'warn',
'no-underscore-dangle': 'off',
'no-unsafe-finally': 'error',
'no-var': 'error',
'prefer-const': [
'warn',
{
'destructuring': 'all'
}
],
'prefer-object-spread': 'warn',
'radix': 'warn',
'spaced-comment': [
'warn',
'always',
{
'markers': [
'/'
],
'exceptions': [
'*'
]
}
],
'space-infix-ops': 'warn',
'use-isnan': 'warn'
}
};
};
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ jobs:
node-version: '16'
- name: Build
run: yarn
- name: Lint
run: yarn lint
- name: Test
run: yarn test
111 changes: 0 additions & 111 deletions configs/.eslintrc.js

This file was deleted.

27 changes: 0 additions & 27 deletions configs/base.tsconfig.json

This file was deleted.

6 changes: 3 additions & 3 deletions examples/circlegraph/src/di.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { CircleNodeView } from './views';

const NodeCreator = Symbol('NodeCreator');

export default (nodeCreator: (point?: Point)=>void) => {
export default (nodeCreator: (point?: Point) => void) => {
require('sprotty/css/sprotty.css');
require('../css/diagram.css');

Expand Down Expand Up @@ -58,15 +58,15 @@ export default (nodeCreator: (point?: Point)=>void) => {
@injectable()
class DroppableMouseListener extends MouseListener {

@inject(NodeCreator) nodeCreator: (point?: Point)=>void;
@inject(NodeCreator) nodeCreator: (point?: Point) => void;

override dragOver(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] {
event.preventDefault();
return [];
}

override drop(target: SModelElementImpl, event: MouseEvent): (Action | Promise<Action>)[] {
this.nodeCreator({ x: event.offsetX, y:event.offsetY })
this.nodeCreator({ x: event.offsetX, y:event.offsetY });
return [];
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/circlegraph/src/standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ export default async function runCircleGraph() {
async function createNode(point?: Point) {
const viewport = await modelSource.getViewport();
const newElements = addNode(getVisibleBounds(viewport));
if(point) {
const adjust = (offset:number) => {
if (point) {
const adjust = (offset: number) => {
return (offset / viewport.zoom) - (NODE_SIZE / 2);
}
};
newElements[0].position = {
x: viewport.scroll.x + adjust(point.x),
y: viewport.scroll.y + adjust(point.y)
Expand All @@ -99,7 +99,7 @@ export default async function runCircleGraph() {

// Button features
document.getElementById('addNode')!.addEventListener('click', async () => {
createNode()
createNode();
});

document.getElementById('scrambleAll')!.addEventListener('click', async () => {
Expand Down
17 changes: 9 additions & 8 deletions examples/classdiagram/src/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ export class ClassContextMenuService implements IContextMenuService {
@inject(TYPES.ViewerOptions) protected viewerOptions: ViewerOptions;

show(items: MenuItem[], anchor: Anchor, onHide?: (() => void) | undefined): void {
this.actionDispatcher.dispatch(SetPopupModelAction.create(EMPTY_ROOT))
this.actionDispatcher.dispatch(SetPopupModelAction.create(EMPTY_ROOT));
const container = document.getElementById(this.viewerOptions.baseDiv);
// eslint-disable-next-line prefer-const
let menuNode: HTMLDivElement;
const hideMenu = () => {
container?.removeChild(menuNode);
if (onHide) {
onHide()
onHide();
}
}
};
menuNode = this.createMenu(items, hideMenu);
menuNode.style.top = (anchor.y - 5) + 'px'
menuNode.style.left = (anchor.x - 5) + 'px'
menuNode.style.top = (anchor.y - 5) + 'px';
menuNode.style.left = (anchor.x - 5) + 'px';


container?.appendChild(menuNode);
Expand All @@ -65,7 +66,7 @@ export class ClassContextMenuService implements IContextMenuService {
if (itemEnabled && item.actions.length > 0) {
this.actionDispatcher.dispatchAll(item.actions);
}
}
};
menuNode.appendChild(menuItem);
});
return menuNode;
Expand All @@ -78,7 +79,7 @@ export class ClassContextMenuItemProvider implements IContextMenuItemProvider {
@inject(TYPES.IActionDispatcher) readonly actionDispatcher: IActionDispatcher;

async getItems(root: Readonly<SModelRootImpl>, lastMousePosition?: Point | undefined): Promise<LabeledAction[]> {
const selectionResult = await this.actionDispatcher.request<SelectionResult>(GetSelectionAction.create())
const selectionResult = await this.actionDispatcher.request<SelectionResult>(GetSelectionAction.create());
return [
new LabeledAction('Fit Diagram to Screen', [FitToScreenAction.create(root.children.map(child => child.id))]),
new LabeledAction('Center Selection', [CenterAction.create(selectionResult.selectedElementsIDs)]),
Expand All @@ -88,7 +89,7 @@ export class ClassContextMenuItemProvider implements IContextMenuItemProvider {
{
...new LabeledAction('Delete Selected', [DeleteElementAction.create(selectionResult.selectedElementsIDs)]),
isEnabled: () => {
return selectionResult.selectedElementsIDs.length > 0
return selectionResult.selectedElementsIDs.length > 0;
}
} as MenuItem
];
Expand Down
Loading

0 comments on commit 4787ce3

Please sign in to comment.