Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(build): add prettier + prettier & lint scripts #9

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
229 changes: 121 additions & 108 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint",
"eslint-plugin-unicorn",
"eslint-plugin-import"
"@typescript-eslint",
"eslint-plugin-unicorn",
"eslint-plugin-import"
],
"env": {
"es6": true,
"node": true
"es6": true,
"node": true
},
"parserOptions": {
"sourceType": "module",
"project": "./tsconfig.json"
"sourceType": "module",
"project": "./tsconfig.json"
},
"extends": [
"plugin:unicorn/recommended"
],
"extends": ["plugin:unicorn/recommended"],
"rules": {
"no-dupe-keys": "warn",
"no-duplicate-case": "warn",
Expand Down Expand Up @@ -68,9 +66,11 @@
"@typescript-eslint/no-shadow": "warn",
"no-shadow-restricted-names": "warn",
"no-undef-init": "warn",
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-unused-vars": [
"warn",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"array-bracket-newline": ["warn", "consistent"],
"array-bracket-spacing": ["warn", "always"],
"block-spacing": ["warn", "always"],
"brace-style": ["warn", "1tbs", { "allowSingleLine": true }],
"comma-dangle": ["warn", "always-multiline"],
Expand All @@ -87,17 +87,6 @@
"new-parens": "warn",
"no-array-constructor": "warn",
"no-lonely-if": "warn",
"no-mixed-operators": ["warn", {
"groups": [
["+", "-", "*", "/", "%", "**"],
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["+", "-", "*", "/", "%", "**", ">", ">=", "<", "<="],
["in", "instanceof"]
],
"allowSamePrecedence": true
}],
"no-multiple-empty-lines": ["warn", { "max": 1 }],
"no-new-object": "warn",
"no-trailing-spaces": "warn",
Expand All @@ -112,11 +101,14 @@
"@typescript-eslint/semi": "warn",
"semi-spacing": "warn",
"space-before-blocks": "warn",
"@typescript-eslint/space-before-function-paren": ["warn", {
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}],
"@typescript-eslint/space-before-function-paren": [
"warn",
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always"
}
],
"array-element-newline": ["warn", "consistent"],
"@typescript-eslint/require-await": "warn",
"space-in-parens": "warn",
Expand All @@ -142,16 +134,19 @@
"object-shorthand": "warn",
"prefer-arrow-callback": "warn",
"prefer-const": "warn",
"prefer-destructuring": ["warn", {
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": false,
"object": false
}
}],
"prefer-destructuring": [
"warn",
{
"VariableDeclarator": {
"array": false,
"object": true
},
"AssignmentExpression": {
"array": false,
"object": false
}
}
],
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"rest-spread-spacing": ["warn", "never"],
Expand All @@ -160,24 +155,30 @@
"yield-star-spacing": "warn",
"@typescript-eslint/adjacent-overload-signatures": ["warn"],
"@typescript-eslint/array-type": ["warn", { "default": "array-simple" }],
"@typescript-eslint/explicit-member-accessibility": ["warn", {
"accessibility": "explicit",
"overrides": {
"accessors": "off",
"constructors": "no-public",
"parameterProperties": "off"
}
}],
"@typescript-eslint/member-delimiter-style": ["warn", {
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}],
"@typescript-eslint/explicit-member-accessibility": [
"warn",
{
"accessibility": "explicit",
"overrides": {
"accessors": "off",
"constructors": "no-public",
"parameterProperties": "off"
}
}
],
"@typescript-eslint/member-delimiter-style": [
"warn",
{
"multiline": {
"delimiter": "semi",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/method-signature-style": ["warn", "property"],
"@typescript-eslint/no-empty-interface": "warn",
"@typescript-eslint/no-extraneous-class": "warn",
Expand All @@ -192,72 +193,84 @@
"unicorn/prefer-module": "off",
"unicorn/no-process-exit": "off",
"unicorn/no-null": "off",
"unicorn/prevent-abbreviations": ["error", {
"replacements": {
"args": false,
"db": false,
"idx": false,
"i": false
}
}],
"unicorn/prevent-abbreviations": [
"error",
{
"replacements": {
"args": false,
"db": false,
"idx": false,
"i": false
}
}
],
"unicorn/no-await-expression-member": "off",
"unicorn/no-new-array": "off",
"unicorn/no-instanceof-array": "off",
"padding-line-between-statements": [
"error",
{
"blankLine": "always",
"prev": "multiline-block-like",
"next": "*"
},
{
"blankLine": "any",
"prev": "if",
"next": "if"
}
"error",
{
"blankLine": "always",
"prev": "multiline-block-like",
"next": "*"
},
{
"blankLine": "any",
"prev": "if",
"next": "if"
}
],
"import/no-unresolved": "off",
"import/named": "off",
"import/default": "error",
"import/export": "error",
"import/order": "warn",
"unicorn/no-array-callback-reference": "off",
"unicorn/prefer-number-properties": ["warn", {
"checkInfinity": false
}],
"unicorn/numeric-separators-style": ["warn", {
"hexadecimal": {
"minimumDigits": 0,
"groupLength": 2,
"onlyIfContainsSeparator": true
},
"binary": {
"minimumDigits": 0,
"groupLength": 4,
"onlyIfContainsSeparator": true
},
"octal": {
"minimumDigits": 0,
"groupLength": 4,
"onlyIfContainsSeparator": true
},
"number": {
"minimumDigits": 5,
"groupLength": 3,
"onlyIfContainsSeparator": false
}
}],
"unicorn/prefer-number-properties": [
"warn",
{
"checkInfinity": false
}
],
"unicorn/numeric-separators-style": [
"warn",
{
"hexadecimal": {
"minimumDigits": 0,
"groupLength": 2,
"onlyIfContainsSeparator": true
},
"binary": {
"minimumDigits": 0,
"groupLength": 4,
"onlyIfContainsSeparator": true
},
"octal": {
"minimumDigits": 0,
"groupLength": 4,
"onlyIfContainsSeparator": true
},
"number": {
"minimumDigits": 5,
"groupLength": 3,
"onlyIfContainsSeparator": false
}
}
],
"unicorn/no-array-reduce": "off",
"unicorn/no-array-method-this-argument": "off",
"unicorn/no-array-for-each": "off",
"unicorn/consistent-function-scoping": "off",
"unicorn/no-nested-ternary": "off",
"@typescript-eslint/explicit-function-return-type": ["warn", {
"allowExpressions": true,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true,
"allowDirectConstAssertionInArrowFunctions": true,
"allowConciseArrowFunctionExpressionsStartingWithVoid": false
}]
"@typescript-eslint/explicit-function-return-type": [
"warn",
{
"allowExpressions": true,
"allowTypedFunctionExpressions": true,
"allowHigherOrderFunctions": true,
"allowDirectConstAssertionInArrowFunctions": true,
"allowConciseArrowFunctionExpressionsStartingWithVoid": false
}
]
}
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
dist
*.tgz
package-lock.json
package-lock.json
.vscode
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"singleQuote": true,
"trailingComma": "all",
"tabWidth": 2,
"bracketSpacing": true,
"semi": true
}
11 changes: 0 additions & 11 deletions .vscode/settings.json

This file was deleted.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
"types": "dist/index.d.ts",
"scripts": {
"test:watch": "TZ=UTC vitest watch -c ./src/vitest.config.ts",
"test": "TZ=UTC vitest run -c ./src/vitest.config.ts"
"test": "TZ=UTC vitest run -c ./src/vitest.config.ts",
"lint": "eslint --ignore-path .gitignore --ext .ts .",
"lint:fix": "eslint --ignore-path .gitignore --ext .ts . --fix && npm run format:fix",
"format:fix": "prettier --ignore-path .gitignore --write \"**/*.+(ts|json)\""
},
"author": "Bartosz Krol <[email protected]>",
"license": "MIT",
Expand All @@ -22,6 +25,7 @@
"eslint-import-resolver-node": "^0.3.6",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-unicorn": "^39.0.0",
"prettier": "^3.1.1",
"type-fest": "^3.0.0",
"typescript": "^4.8.3",
"vitest": "^0.34.6"
Expand Down
4 changes: 3 additions & 1 deletion src/__tests__/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ describe('test HolyTime.add', () => {
it('should handle adding with non-standard units', () => {
const date = new HolyTime(new Date('2023-01-01T00:00:00.000Z'));
// @ts-expect-error
expect(() => date.add(1, 'nonStandardUnit')).toThrow('Invalid unit: nonStandardUnit');
expect(() => date.add(1, 'nonStandardUnit')).toThrow(
'Invalid unit: nonStandardUnit',
);
});
});
Loading
Loading