-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
3,046 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Automatic tests | ||
|
||
After completing all the steps in the project, automatic tests will become available to you. Tests are run on each commit - once all tasks in the Hexlet interface are completed, make a commit, and the tests will run automatically. | ||
|
||
The hexlet-check.yml file is responsible for running these tests - do not delete this file, edit it, or rename the repository. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
install: | ||
npm ci | ||
|
||
brain-games: | ||
node bin/brain-games.js | ||
|
||
brain-even: | ||
node bin/brain-even.js | ||
|
||
publish: | ||
npm publish --dry-run | ||
|
||
lint: | ||
npx eslint . | ||
|
||
lint-fix: | ||
npx eslint --fix . | ||
|
||
link: | ||
npm link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Hexlet tests and linter status: | ||
[![Actions Status](https://github.com/sazanik/backend-project-lvl1/actions/workflows/hexlet-check.yml/badge.svg)](https://github.com/sazanik/backend-project-lvl1/actions) | ||
|
||
[![Maintainability](https://api.codeclimate.com/v1/badges/33bad7646aa4a2a98d3e/maintainability)](https://codeclimate.com/github/sazanik/backend-project-lvl1/maintainability) | ||
|
||
[![asciicast](https://asciinema.org/a/NHYTq1gdMy5sydEDQ1CL5RzEV.svg)](https://asciinema.org/a/NHYTq1gdMy5sydEDQ1CL5RzEV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env node | ||
|
||
import BrainGames from './brain-games.js'; | ||
|
||
const brainGames = new BrainGames(); | ||
|
||
brainGames.evenGame(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env node | ||
|
||
import { ATTEMPTS_COUNT } from '../src/constants/index.js'; | ||
import { askAndGetName, askNumIsEven, congratulate } from '../src/cli.js'; | ||
|
||
class BrainGames { | ||
attemptsCount; | ||
|
||
name; | ||
|
||
constructor(attemptsCount = ATTEMPTS_COUNT) { | ||
this.attemptsCount = attemptsCount; | ||
this.name = askAndGetName(); | ||
this.congratulate = congratulate; | ||
} | ||
|
||
evenGame() { | ||
console.log('Answer "yes" if the number is even, otherwise answer "no".'); | ||
|
||
const answersArr = []; | ||
|
||
for (let i = 0; i < this.attemptsCount; i += 1) { | ||
const num = Math.round(Math.random() * 1000); | ||
|
||
answersArr.push(askNumIsEven(num)); | ||
} | ||
|
||
if (answersArr.every(Boolean)) { | ||
this.congratulate(this.name); | ||
return; | ||
} | ||
|
||
// TODO: need to replace | ||
console.log('You\'ve lost, try again!'); | ||
} | ||
} | ||
|
||
export default BrainGames; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import globals from 'globals'; | ||
|
||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { FlatCompat } from '@eslint/eslintrc'; | ||
import pluginJs from '@eslint/js'; | ||
import importPlugin from 'eslint-plugin-import'; | ||
|
||
// mimic CommonJS variables -- not needed if using CommonJS | ||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
const compat = new FlatCompat({ | ||
baseDirectory: __dirname, | ||
recommendedConfig: pluginJs.configs.recommended, | ||
}); | ||
|
||
export default [ | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...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: 'latest', | ||
sourceType: 'module', | ||
}, | ||
}, | ||
plugins: { import: importPlugin }, | ||
rules: { | ||
...importPlugin.configs.recommended.rules, | ||
}, | ||
}, | ||
...compat.extends('airbnb-base'), | ||
{ | ||
rules: { | ||
'max-len': ['error', { code: 120, ignoreComments: true }], | ||
'no-underscore-dangle': [ | ||
'error', | ||
{ | ||
allow: ['__filename', '__dirname'], | ||
}, | ||
], | ||
'import/extensions': [ | ||
'error', | ||
'ignorePackages', | ||
{ | ||
js: 'always', | ||
}, | ||
], | ||
'import/no-named-as-default': 'off', | ||
'import/no-named-as-default-member': 'off', | ||
'no-console': 'off', | ||
'import/no-extraneous-dependencies': 'off', | ||
'import/prefer-default-export': 'off', | ||
}, | ||
}, | ||
]; |
Oops, something went wrong.