Skip to content

Commit

Permalink
feat: init eslint + add makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
hecht-a committed Sep 5, 2022
1 parent 780f2a3 commit 89d8ccb
Show file tree
Hide file tree
Showing 6 changed files with 247 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
lib
tsconfig.json
package.json
.eslintrc.json
rollup.config.ts
121 changes: 121 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"airbnb-typescript/base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:json/recommended"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"import"
],
"rules": {
"@typescript-eslint/no-shadow": 0,
"guard-for-in": 0,
"multiline-ternary": [
"error",
"always"
],
"@typescript-eslint/indent": [
"error",
"tab",
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"@typescript-eslint/quotes": [
"error",
"double",
{
"allowTemplateLiterals": true
}
],
"eqeqeq": [
"error",
"always"
],
"no-else-return": [
"error",
{
"allowElseIf": false
}
],
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-multi-spaces": [
"warn",
{
"ignoreEOLComments": true
}
],
"yoda": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
"args": "none"
}
],
"no-tabs": "off",
"max-len": [
"error",
{
"code": 120,
"ignoreComments": true
}
],
"no-console": "off",
"consistent-return": "off",
"class-methods-use-this": "off",
"import/prefer-default-export": "off",
"no-plusplus": "off",
"no-nested-ternary": "error",
"no-return-assign": "off",
"no-restricted-syntax": "off",
"no-await-in-loop": "off",
"no-mixed-spaces-and-tabs": [
"error",
"smart-tabs"
],
"import/no-cycle": "off",
"@typescript-eslint/explicit-function-return-type": "warn",
"import/extensions": "off",
"no-underscore-dangle": [
"error",
{
"allowAfterThis": true
}
],
"no-continue": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"@typescript-eslint/explicit-module-boundary-types": "off",
"no-void": "off",
"curly": [
"error",
"all"
],
"no-return-await": "error"
}
}
33 changes: 33 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.SILENT:

PACKAGE_VERSION=$(shell cat package.json | grep -i version | sed -e "s/ //g" | cut -c 12- | sed -e "s/\",//g")

.PHONY: install
install:
pnpm install

.PHONY: build
build:
pnpm run build

.PHONY: lint
lint:
pnpm run lint

.PHONY: npmjs
npmjs:
echo "//registry.npmjs.org/:_authToken=$$NPM_TOKEN" >> .npmrc
echo "@hecht-a:registry=https://registry.npmjs.org/" >> .npmrc

.PHONY: publish-npmjs
publish-npmjs:
yarn publish --access public --registry https://registry.npmjs.org/ --new-version $(PACKAGE_VERSION) --non-interactive

.PHONY: github-tag
github-tag:
git tag -a v$(PACKAGE_VERSION) -m "update to v$(PACKAGE_VERSION)"
git push origin v$(PACKAGE_VERSION)

.PHONY: types
types:
pnpm run types
43 changes: 36 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
{
"name": "form-validator",
"private": true,
"name": "@hecht-a/form-validator",
"version": "1.0.0",
"description": "This is a package to validate forms in frontend.",
"private": false,
"type": "module",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib"
],
"author": {
"name": "Axel Hecht",
"url": "https://github.com/hecht-a"
},
"bugs": {
"url": "https://github.com/hecht-a/form-validator/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/hecht-a/form-validator.git"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
"build": "rollup --config rollup.config.ts",
"types": "tsc --declaration --emitDeclarationOnly --project tsconfig.types.json",
"lint": "eslint --ext .ts,.js ."
},
"devDependencies": {
"typescript": "^4.6.4",
"vite": "^3.0.7"
"@rollup/plugin-typescript": "^8.4.0",
"@typescript-eslint/eslint-plugin": "^4.33.0",
"@typescript-eslint/parser": "^4.33.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-json": "^2.1.2",
"rollup": "^2.79.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-terser": "^7.0.2",
"tslib": "^2.4.0",
"typescript": "^4.8.2",
"vite": "^3.1.0"
}
}
43 changes: 43 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import remove from "rollup-plugin-delete";
import {resolve} from "node:path";
import {terser} from "rollup-plugin-terser";
import typescript from "@rollup/plugin-typescript";

export default [
{
input: resolve("src", "Validator/index.ts"),
plugins: [
remove({targets: resolve("lib", "*")}),
typescript(),
terser()
],
output: {
file: resolve("lib", "Validator/index.js"),
format: "cjs"
}
},
{
input: resolve("src", "Error/index.ts"),
plugins: [
remove({targets: resolve("lib", "*")}),
typescript(),
terser()
],
output: {
file: resolve("lib", "Error/index.js.js"),
format: "cjs"
}
},
{
input: resolve("src", "index.ts"),
plugins: [
remove({targets: resolve("lib", "*")}),
typescript(),
terser()
],
output: {
file: resolve("lib", "index.js"),
format: "cjs"
}
}
];
9 changes: 9 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"files": ["src/index.ts"],
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"outDir": "./lib"
}
}

0 comments on commit 89d8ccb

Please sign in to comment.