From ccdcce0885d7fabf45d52ef2700b5472b49274b5 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Fri, 6 Aug 2021 16:03:14 +0300 Subject: [PATCH] Added eslint and prettier --- .eslintignore | 2 ++ .eslintrc | 11 +++++++++++ .github/workflows/lint.yaml | 14 ++++++++++++++ .github/workflows/test.yaml | 2 +- .prettierignore | 2 ++ .prettierrc | 7 +++++++ README.md | 6 +++--- package.json | 10 +++++++++- src/__tests__/index.html | 11 ++++++----- src/__tests__/index.test.ts | 26 +++++++++++++------------- src/index.ts | 28 ++++++++++++++-------------- 11 files changed, 82 insertions(+), 37 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 .github/workflows/lint.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..46f1072 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +lib/ +node_modules/ \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..70bf062 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,11 @@ +{ + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2020, + "sourceType": "module" + }, + "extends": [ + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ] +} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..2dc9a74 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,14 @@ +name: Lint CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: npm install + - run: npm run lint diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index f817bc1..3063e88 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -9,6 +9,6 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: - node-version: "14" + node-version: '14' - run: npm install - run: npm test diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..46f1072 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +lib/ +node_modules/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6bdf86a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": true, + "printWidth": 80, + "tabWidth": 2 +} diff --git a/README.md b/README.md index 477d6d0..cdb67d8 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ It is a plugin for HTML document pagination to fit fixed-sized container. This o In a browser environment import `HTMLPagination` class and create it's instance: ```js -import { HTMLPagination } from "html-pagination"; +import { HTMLPagination } from 'html-pagination'; const pg = new HTMLPagination( - document.getElementById("content"), // HTML element with html content you want to paginate in it - document.getElementById("container"), // HTML element which will display page content. It must add scrollbar on overflow + document.getElementById('content'), // HTML element with html content you want to paginate in it + document.getElementById('container'), // HTML element which will display page content. It must add scrollbar on overflow 100 // Initial number of characters per page. Good value will increase speed of first page computation ); ``` diff --git a/package.json b/package.json index 509a551..8f8b27c 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,8 @@ "scripts": { "test:browser": "npm run build -- --module 'esnext' && cp ./src/__tests__/index.html ./lib/ && bash -c 'for module in \".\\/cache\" \".\\/types\" \".\\/utils\"; do sed -i \"s/$module/$module.js/g\" ./lib/index.js; done' && serve -s lib", "build": "rm -rf lib && tsc", + "lint": "eslint .", + "format": "prettier --write .", "test": "jest --config jestconfig.json --passWithNoTests", "prepare": "npm run build", "prepublishOnly": "npm test && npm run lint", @@ -33,9 +35,15 @@ "homepage": "https://github.com/dm1sh/html-pagination#readme", "devDependencies": { "@types/jest": "^26.0.24", + "@typescript-eslint/eslint-plugin": "^4.29.0", + "@typescript-eslint/parser": "^4.29.0", "esbuild": "^0.12.17", "esbuild-jest": "^0.5.0", + "eslint": "^7.32.0", "jest": "^27.0.6", - "typescript": "^4.3.5" + "typescript": "^4.3.5", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-prettier": "^3.4.0", + "prettier": "^2.3.2" } } diff --git a/src/__tests__/index.html b/src/__tests__/index.html index acd3c6a..c03d9f7 100644 --- a/src/__tests__/index.html +++ b/src/__tests__/index.html @@ -26,24 +26,25 @@ }
+

About me

Hello, I'm Shishkov Dmitriy. I'm 17 years old computer programmer. I'm also do photography as a hobby. As for spring 2021, I'm studying in "Ugra physico-mathematical boarding school" in Khanty-Mansiysk.

My specialization is frontend web development. All web services and application I deploy on my own. For it I've used Dockerand docker-composefor deployment on my VPS. Currently my server is powered with Dokku. For smaller projects I also used some PaaS like Herokuand Vercel Now.

I also do in for C development. In projectssection you can see some of my developments in this langualge. Even this site is powered by page generator written in C.

More formally, this is my stack:

See contactsto get in touch with me.

You can reach my resume following this link