Skip to content

Commit

Permalink
feat: add new utility functions, tests and update project settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sazanik committed Nov 20, 2024
1 parent 560c09a commit 099dec0
Show file tree
Hide file tree
Showing 21 changed files with 6,893 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Makefile]
indent_style = tab

[*.js]
indent_style = space
indent_size = 2
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '23.x'

- name: Install dependencies
run: make install

- name: Run tests
run: make test

- name: Run linter
run: make lint

- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageCommand: make test-coverage
debug: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
coverage
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node-options=--no-warnings --experimental-vm-modules
engine=jest
max_old_space_size=4096
3 changes: 3 additions & 0 deletions .watchmanconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["node_modules", ".git"]
}
27 changes: 22 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
install:
npm ci

gen-diff:
node bin/brain-games.js

publish:
npm publish --dry-run

link:
npm link
install: deps-install
npx simple-git-hooks

gen-diff-demonstration:
node bin/gen-diff.js __fixtures__/file1.json __fixtures__/file2.json

deps-install:
npm ci --legacy-peer-deps

deps-update:
npx ncu -u

test:
npx jest

test-coverage:
npx jest --coverage --coverageProvider=v8

lint:
npx eslint .

.PHONY: test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

[![Actions Status](https://github.com/sazanik/frontend-project-46/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/sazanik/frontend-project-46/actions)
[![Maintainability](https://api.codeclimate.com/v1/badges/340d808eecf9f8cd511a/maintainability)](https://codeclimate.com/github/sazanik/frontend-project-46/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/340d808eecf9f8cd511a/test_coverage)](https://codeclimate.com/github/sazanik/frontend-project-46/test_coverage)
8 changes: 8 additions & 0 deletions __fixtures__/result.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
- follow: false
host: hexlet.io
- proxy: 123.234.53.22
- timeout: 50
+ timeout: 20
+ verbose: true
}
81 changes: 81 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import globals from 'globals';
import { FlatCompat } from '@eslint/eslintrc';
import pluginJs from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import eslintConfigPrettier from 'eslint-config-prettier';

import { __dirname } from './globals.js';

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: pluginJs.configs.recommended,
});

export default [
{
settings: {
'import/resolver': {
node: {
extensions: ['.js'],
},
},
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.jest,
},
parserOptions: {
// Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
// This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
ecmaVersion: 2025,
sourceType: 'module',
},
},
plugins: {
import: importPlugin,
},
rules: {
...importPlugin.configs.recommended.rules,
},
},
...compat.extends('airbnb-base'),
{
rules: {
'no-underscore-dangle': [
'error',
{
allow: ['__filename', '__dirname'],
},
],
'import/extensions': [
'error',
{
js: 'always',
},
],
// FIXME: getting error with ?? operator, when enabled
'import/named': ['off'],
'import/no-named-as-default': 'off',
'import/no-named-as-default-member': 'off',
'import/no-extraneous-dependencies': 'off',
'import/prefer-default-export': 'off',
'max-len': ['warn', { code: 120 }],
'no-unused-vars': 'error',
'no-console': 'off',
'no-debugger': 'warn',
'prefer-const': 'error',
'import/no-unresolved': 'error',
'import/order': [
'error', {
'newlines-between': 'always',
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
}],
indent: ['error', 2],
semi: ['error', 'always'],
quotes: ['error', 'single'],
},
},
eslintConfigPrettier,
];
5 changes: 5 additions & 0 deletions globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { fileURLToPath } from 'url';
import path from 'path';

export const __filename = fileURLToPath(import.meta.url);
export const __dirname = path.dirname(__filename);
Loading

0 comments on commit 099dec0

Please sign in to comment.