Skip to content

Commit

Permalink
implemented eslint and prettier setup
Browse files Browse the repository at this point in the history
added .vscode and prettier configs

created npm run script for prettier

added eslint and npm script for it

added eslint and prettier to contributing file
  • Loading branch information
AndreWillomitzer committed Nov 2, 2021
1 parent 8a584a3 commit f9591ce
Show file tree
Hide file tree
Showing 12 changed files with 2,122 additions and 176 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
@@ -0,0 +1,8 @@
dist
package.json
package-lock.json
node_modules/
Sherlock_Holmes_Selected_Stories/
*.json
*.html
*.md
26 changes: 26 additions & 0 deletions .eslintrc.json
@@ -0,0 +1,26 @@
{
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],

"plugins": [
"prettier"
],
"env":{
"es6": true,
"node": true,
"browser": true
},
"rules": {
"prettier/prettier": "error",
"no-const-assign":"error",
"no-irregular-whitespace": "warn",
"no-await-in-loop": "warn",
"no-unused-vars":"error",
"no-alert":"error",
"no-empty":"warn",
"arrow-spacing":"warn",
"no-trailing-spaces":"warn"
}
}
9 changes: 9 additions & 0 deletions .prettierignore
@@ -0,0 +1,9 @@
# ignore artifacts:
dist
package.json
package-lock.json
node_modules/
Sherlock_Holmes_Selected_Stories/
*.json
*.html
*.md
7 changes: 7 additions & 0 deletions .prettierrc.json
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"semi": true,
"useTabs": false,
"tabWidth": 2,
"endOfLine": "lf"
}
8 changes: 8 additions & 0 deletions .vscode/extensions.json
@@ -0,0 +1,8 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
}
9 changes: 9 additions & 0 deletions .vscode/settings.json
@@ -0,0 +1,9 @@
{
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.detectIndentation": false,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"files.eol" : "\n",
"files.insertFinalNewline": true
}
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,36 @@
# textToHTML_V2 Contribution Guidelines

### Requirements

- Current version of NodeJS.
- npm package manager.

### Installation

- Clone the repository and fork your clone.
- Navigate to the folder you cloned.
- cd into the project folder.
- `npm install` to download dependencies.

### Development

- Create a branch for your work.
- Make your changes and save.
- Check which files were modified using git status.
- Stage these changed files in git (eg. git add file1 file2)
- Commit your changes, git commit -m "description of changes here..."
- Push your commits and branch to your fork, git push origin {your branch name}
- Create a pull request on GitHub detailing your changes and how you tested your solution.

### Development Checks

#### Eslint

- `npm run lint` will run all JavaScript files against the project style guides found in **.eslintrc**. Excludes md, html, css, json files.
- `npm run eslint-fix` will do the same as `lint` and also "fix" any errors.
- `npm run eslint` is the same as the first command, but more typing.

#### Prettier

- `npm run prettier-check` runs a check against the prettier style guide found in **prettierrc.json** for all JavaScript files. Excludes md, html, css, json files.
- `npm run prettier` runs the same check and adds --write option to attempt to fix the style issues.
75 changes: 47 additions & 28 deletions README.md
Expand Up @@ -3,39 +3,49 @@
### Description:

```
textToHTML is a file and folder parser to generate HTML files from txt and markdown files. It can be run from the command line.
The tool also supports markdown features for h1 and h2 tags.
textToHTML is a file and folder parser to generate HTML files from txt and markdown files. It can be run from the command line.
The tool also supports markdown features.
To install the tool download the source code. Make sure to have an updated version of nodeJS and npm installed. On the command line, type npm install.
```
### Usage:

### Usage:

```
Input is required, stylesheet and output folder are optional. Default output folder is "./dist".
***Paths to input files/folders must be absolute unless in present working directory.
```

### Examples:

```
node textToHTML -i <filename/foldername> -s <stylesheet url or path> -o <alternate folder output>
node textToHTML --input <filename/foldername> --stylesheet <stylesheet url or path> --output <alternate folder output>
node textToHTML --input <filename/foldername> --stylesheet <stylesheet url or path>
node textToHTML --input <filename/foldername> --stylesheet <stylesheet url or path>
node textToHTML -c <config JSON filename>
```

### Features

```
- Supports outputting to a specified folder.
- Allows adding of custom stylesheets to generated HTML files.
- If a Markdown file is provided, h1 and h2 headings may be generated using "#" and "##" respectively.
- Read config file properties and uses them in place of command line arguments.
```

### Support

```
- node textToHTML.js --help or -h displays a help menu with options/commands available.
```

### Sample Output

##### The Input Text:

```
I was not surprised. Indeed, my only wonder was that he had not
already been mixed up in this extraordinary case, which was the
Expand All @@ -57,11 +67,13 @@ what I had both expected and hoped for.
“I should be most happy to go down with you if I should not be in
the way,” said I.
```

##### The Output HTML:

```html
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
Expand All @@ -80,7 +92,7 @@ challenge his powers of analysis, and that was the singular
disappearance of the favourite for the Wessex Cup, and the tragic
murder of its trainer. When, therefore, he suddenly announced his
intention of setting out for the scene of the drama it was only
what I had both expected and hoped for.</p> </br>
what I had both expected and hoped for.</p> </br>
<p>“I should be most happy to go down with you if I should not be in the way,” said I.</p> </br>
</body>
</html>
Expand All @@ -89,6 +101,7 @@ what I had both expected and hoped for.</p> </br>
## NEW FEATURE: Markdown h1 and h2

#### The Input Markdown:

```
I was not surprised. Indeed, my only wonder was that he had not
already been mixed up in this extraordinary case, which was the
Expand All @@ -110,31 +123,37 @@ what I had both expected and hoped for.
# “I should be most happy to go down with you if I should not be in
the way,” said I.
```

##### The Output HTML:

```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<p>I was not surprised. Indeed, my only wonder was that he had not already been mixed up in this extraordinary case, which was the
one topic of conversation through the length and breadth of
England. For a whole day my companion had rambled about the room
with his chin upon his chest and his brows knitted, charging and
recharging his pipe with the strongest black tobacco, and
absolutely deaf to any of my questions or remarks. Fresh editions
of every paper had been sent up by our news agent, only to be
glanced over and tossed down into a corner. Yet, silent as he
was, I knew perfectly well what it was over which he was
brooding. There was but one problem before the public which could
challenge his powers of analysis, and that was the singular
disappearance of the favourite for the Wessex Cup, and the tragic
murder of its trainer. When, therefore, he suddenly announced his
intention of setting out for the scene of the drama it was only
what I had both expected and hoped for.</p>
<h1>“I should be most happy to go down with you if I should not be in the way,” said I.</h1>
</body>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<p>
I was not surprised. Indeed, my only wonder was that he had not already
been mixed up in this extraordinary case, which was the one topic of
conversation through the length and breadth of England. For a whole day my
companion had rambled about the room with his chin upon his chest and his
brows knitted, charging and recharging his pipe with the strongest black
tobacco, and absolutely deaf to any of my questions or remarks. Fresh
editions of every paper had been sent up by our news agent, only to be
glanced over and tossed down into a corner. Yet, silent as he was, I knew
perfectly well what it was over which he was brooding. There was but one
problem before the public which could challenge his powers of analysis,
and that was the singular disappearance of the favourite for the Wessex
Cup, and the tragic murder of its trainer. When, therefore, he suddenly
announced his intention of setting out for the scene of the drama it was
only what I had both expected and hoped for.
</p>
<h1>
“I should be most happy to go down with you if I should not be in the
way,” said I.
</h1>
</body>
</html>
```

0 comments on commit f9591ce

Please sign in to comment.