Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Merge pull request #59 from lars-reimann/strict_linting
Browse files Browse the repository at this point in the history
Add custom configuration for ESLint
  • Loading branch information
lars-reimann authored Jun 18, 2021
2 parents 7652a04 + 7a46e7a commit c90b935
Show file tree
Hide file tree
Showing 34 changed files with 267 additions and 233 deletions.
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

2 changes: 2 additions & 0 deletions client/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
node_modules
29 changes: 29 additions & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// eslint-disable-next-line no-undef
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: [
"@typescript-eslint",
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
"eol-last": [
"warn",
"always"
],
"no-extra-semi": "warn",
"semi": [
"warn",
"always"
],
"@typescript-eslint/no-this-alias": [
"error",
{
"allowedNames": ["current"]
}
]
}
};
6 changes: 0 additions & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@
"predeploy": "yarn run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
7 changes: 4 additions & 3 deletions client/src/Components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import './App.css';
import ParameterView from "../ParameterView/ParameterView";
import TreeView from "../TreeView/TreeView";
import PythonFunction from "../../model/PythonFunction";
import PythonParameter from "../../model/PythonParameter";

function App() {
function App(): JSX.Element {

const [parameters, setParameters] = useState([]);
const [selection, setSelection] = useState([]);
const [parameters, setParameters] = useState<PythonParameter[]>([]);
const [selection, setSelection] = useState<string[]>([]);
const [selectedFunction, setSelectedFunction] = useState<Nullable<PythonFunction>>(null);

return (
Expand Down
13 changes: 7 additions & 6 deletions client/src/Components/ParameterView/DocumentationText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
import classNames from "classnames";

// @ts-ignore
const DocumentationText = ({inputText = ""}) => {
type DocumentationTextProps = {
inputText: string
}

export default function DocumentationText({inputText = ""}: DocumentationTextProps): JSX.Element {

const shortenedText = inputText.split("\n\n")[0];
const hasMultipleLines = shortenedText !== inputText;
Expand All @@ -21,7 +24,7 @@ const DocumentationText = ({inputText = ""}) => {

return (
<div className="docu-paragraph" onClick={() => {
setReadMore(!readMore)
setReadMore(!readMore);
}}>
{!readMore && hasMultipleLines && "▶"}
{readMore && hasMultipleLines && "▼"}
Expand All @@ -30,6 +33,4 @@ const DocumentationText = ({inputText = ""}) => {

</div>
);
};

export default DocumentationText;
}
7 changes: 2 additions & 5 deletions client/src/Components/ParameterView/ParameterNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Dropdown } from "react-bootstrap";

type ParameterProps = {inputParameter: PythonParameter}

const ParameterNode = ({inputParameter}: ParameterProps) => {
export default function ParameterNode({inputParameter}: ParameterProps): JSX.Element {

const hasDescription = !!inputParameter.description;

Expand Down Expand Up @@ -35,7 +35,4 @@ const ParameterNode = ({inputParameter}: ParameterProps) => {

</div>
);
};

export default ParameterNode;

}
31 changes: 14 additions & 17 deletions client/src/Components/ParameterView/ParameterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,37 @@ type ParameterViewProps = {
selectedFunction: Nullable<PythonFunction>
};

const ParameterView = ({inputParameters, selection, selectedFunction}: ParameterViewProps) => {
export default function ParameterView({inputParameters, selection, selectedFunction}: ParameterViewProps): JSX.Element {

const hasInputParameters = inputParameters.length > 0;

return (
<div className="parameter-view">
<div className="parameter-view-path" >
{ selection.length > 0 ?
<div className="parameter-view-path">
{selection.length > 0 ?
// eslint-disable-next-line
selection.map<React.ReactNode>(n => <a href="#">{n}</a>)
.reduce((p, c) => [p, (<span> / </span>), c]) :
"" }
.reduce((p, c) => [p, (<span> / </span>), c]) :
""}
</div>
{ selectedFunction !== null &&
<>
<h1>{selectedFunction.name}</h1>
<DocumentationText inputText={selectedFunction.description} />
</>
{selectedFunction !== null &&
<>
<h1>{selectedFunction.name}</h1>
<DocumentationText inputText={selectedFunction.description}/>
</>
}

<h2 className={"parameter-title"}>Parameters</h2>
{
inputParameters?.map(function (parameters) {
return (<ParameterNode key={parameters.name} inputParameter={parameters} />)
return (<ParameterNode key={parameters.name} inputParameter={parameters}/>);
})
}
{
!hasInputParameters &&
<span>There are no Parameters.</span>
<span>There are no Parameters.</span>
}

</div>
)
};

export default ParameterView;

);
}
24 changes: 11 additions & 13 deletions client/src/Components/Tree/ClassNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import classNames from "classnames";
import FunctionNode from "./FunctionNode";
import {isEmptyList} from "../../util/listOperations";
import PythonFunction from "../../model/PythonFunction";
import PythonParameter from "../../model/PythonParameter";

type ClassNodeProps = {
parentPath: string[],
pythonClass: PythonClass,
selection: string[],
setSelection: (newValue: string[]) => void,
moduleName: string,
setParameters: any,
setParameters: Setter<PythonParameter[]>,
setSelectedFunction: Setter<Nullable<PythonFunction>>
}

const ClassNode = ({
parentPath,
pythonClass,
selection,
setSelection,
moduleName,
setParameters,
setSelectedFunction
}: ClassNodeProps) => {
export default function ClassNode({
parentPath,
pythonClass,
selection,
setSelection,
setParameters,
setSelectedFunction
}: ClassNodeProps): JSX.Element {

const [childVisible, setChildVisibility] = useState(false);
const hasMethods = !isEmptyList(pythonClass.methods);
Expand Down Expand Up @@ -66,6 +66,4 @@ const ClassNode = ({
</div>}
</div>
);
};

export default ClassNode;
}
13 changes: 6 additions & 7 deletions client/src/Components/Tree/FunctionNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ import React from "react";
import PythonFunction from "../../model/PythonFunction";
import classNames from "classnames";
import {isEmptyList} from "../../util/listOperations";
import PythonParameter from "../../model/PythonParameter";

type FunctionNodeProps = {
pythonFunction: PythonFunction,
selection: string[],
setSelection: (newValue: string[]) => void,
setParameters: any,
setParameters: Setter<PythonParameter[]>,
isMethod?: boolean,

/** A parent of a Python class can be a class or a Python module. */
parentPath: string[],
setSelectedFunction: Setter<Nullable<PythonFunction>>
}

const FunctionNode = ({
export default function FunctionNode({
pythonFunction,
selection,
setSelection,
setParameters,
parentPath,
isMethod = false,
setSelectedFunction
}: FunctionNodeProps) => {
}: FunctionNodeProps): JSX.Element {

const path = parentPath.concat(pythonFunction.name)
const path = parentPath.concat(pythonFunction.name);
const hasParameters = !isEmptyList(pythonFunction.parameters);
const cssClasses = classNames(
"tree-view-row", {
Expand Down Expand Up @@ -54,6 +55,4 @@ const FunctionNode = ({
</div>
</div>
);
};

export default FunctionNode;
}
34 changes: 16 additions & 18 deletions client/src/Components/Tree/ModuleNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@ type ModuleNodeProps = {
pythonModule: PythonModule,
selection: string[],
setSelection: (newValue: string[]) => void,
setParameters: any,
setParameters: Setter<string[]>,
setSelectedFunction: Setter<Nullable<PythonFunction>>
}

const ModuleNode = ({
parentPath,
pythonModule,
selection,
setSelection,
setParameters,
setSelectedFunction
}: ModuleNodeProps) => {
export default function ModuleNode({
parentPath,
pythonModule,
selection,
setSelection,
setParameters,
setSelectedFunction
}: ModuleNodeProps): JSX.Element {

/** This is the Name of this module without its packages name prefixed. */

const [, ...moduleName] = pythonModule.name.split(".");

const path = parentPath.concat(moduleName)
const path = parentPath.concat(moduleName);
const [childVisible, setChildVisibility] = useState(false);
let hasClasses = !isEmptyList(pythonModule.classes);
let hasFunctions = !isEmptyList(pythonModule.functions);
const hasClasses = !isEmptyList(pythonModule.classes);
const hasFunctions = !isEmptyList(pythonModule.functions);
const hasChildren = hasClasses || hasFunctions;

const cssClasses = classNames(
Expand All @@ -48,8 +48,8 @@ const ModuleNode = ({
<div className="module-node">
<div className={cssClasses}
onClick={() => {
setSelection(path)
setChildVisibility(!childVisible)
setSelection(path);
setChildVisibility(!childVisible);
}}>
{(hasClasses || hasFunctions) &&
<span className="indicator visibility-indicator">{childVisible ? "▼" : "▶"}</span>}
Expand Down Expand Up @@ -89,7 +89,5 @@ const ModuleNode = ({
</div>}
</div>
</div>
)
};

export default ModuleNode;
);
}
17 changes: 11 additions & 6 deletions client/src/Components/Tree/Tree.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React from 'react'
import React from 'react';
import ModuleNode from "./ModuleNode";
import PythonPackage from "../../model/PythonPackage";
import PythonFunction from "../../model/PythonFunction";
import PythonParameter from "../../model/PythonParameter";

type TreeProps = {
pythonPackage: PythonPackage,
setParameters: any,
setParameters: Setter<PythonParameter[]>,
selection: string[],
setSelection: any,
setSelection: Setter<string[]>,
setSelectedFunction: Setter<Nullable<PythonFunction>>
}

const Tree = ({pythonPackage, setParameters, selection, setSelection, setSelectedFunction}: TreeProps) => {
export default function Tree({
pythonPackage,
setParameters,
selection,
setSelection,
setSelectedFunction
}: TreeProps): JSX.Element {

const path = [pythonPackage.name];

Expand All @@ -30,5 +37,3 @@ const Tree = ({pythonPackage, setParameters, selection, setSelection, setSelecte
</div>
);
}

export default Tree;
Loading

0 comments on commit c90b935

Please sign in to comment.