-
Notifications
You must be signed in to change notification settings - Fork 540
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
1 parent
015ef09
commit a67449d
Showing
11 changed files
with
240 additions
and
1 deletion.
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,28 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
commonjs: true, | ||
es6: true, | ||
node: true, | ||
mocha: true, | ||
}, | ||
extends: ['airbnb-base', 'plugin:prettier/recommended'], | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
}, | ||
parserOptions: { | ||
ecmaVersion: 2022, | ||
}, | ||
rules: { | ||
'prettier/prettier': [ | ||
'error', | ||
{ | ||
endOfLine: 'auto', | ||
}, | ||
], | ||
}, | ||
plugins: ['prettier'], | ||
ignorePatterns: ['extensions/*'], | ||
noInlineConfig: true, | ||
}; |
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
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 @@ | ||
/extensions/* |
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 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"printWidth": 80 | ||
} |
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,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1 +1,98 @@ | ||
# core-js-promises-tasks | ||
# Core JS promises task | ||
|
||
:warning: **Please note that you mustn't open PRs that contains the answers to this repo!** | ||
|
||
However, PRs with the fixes or proposals are welcomed! | ||
|
||
## Task | ||
|
||
The task is to implement functions on different Core JS topics. This module requires solving tasks related to loops and conditions. | ||
|
||
**Active usage of [documentation](https://developer.mozilla.org/en-US/) is strongly recommended!** | ||
|
||
## Prepare and test | ||
|
||
1. Install Node.js | ||
2. Fork this repository: https://github.com/rolling-scopes-school/core-js-promises | ||
3. Clone your newly created repo: `https://github.com/<%your_github_username%>/core-js-promises/` | ||
4. Go to folder `core-js-promises` | ||
5. To install all dependencies use `npm install` | ||
6. Each task is usually a regular function: | ||
|
||
```javascript | ||
/** | ||
* Determines whether a given number is positive. Zero is considered positive. | ||
* | ||
* @param {string} date - date and time. | ||
* @return {number} milliseconds in timestamp. | ||
* | ||
* @example: | ||
* '01 Jan 1970 00:00:00 GMT' => 0 | ||
* '04 Dec 1995 00:12:00 GMT' => 818035920000 | ||
*/ | ||
function dateToTimestamp(/* date */) { | ||
throw new Error('Not implemented'); | ||
} | ||
``` | ||
|
||
Read the task description in the comment above the function. Try to understand the idea. You can see the tests prepared if you don't understand it. | ||
|
||
7. Write your code in `src/core-js-promises-tasks.js`. | ||
|
||
Uncomment the incoming parameters: | ||
|
||
```javascript | ||
function dateToTimestamp(/* date */) | ||
``` | ||
|
||
Remove the throwing error line from function body: | ||
|
||
```javascript | ||
throw new Error('Not implemented'); | ||
``` | ||
|
||
Implement the function by any way and verify your solution by running tests until the failed test become passed (green). | ||
|
||
8. Save the solution and run `npm test` in command line. If everything is OK you can try to resolve the next task. | ||
|
||
## Submit to [rs app](https://app.rs.school/) | ||
|
||
1. Commit and push your solutions to your fork | ||
2. Open [rs app](https://app.rs.school/) and login | ||
3. Go to [submit task page](https://app.rs.school/course/submit-task?course=rs-2023-q4) | ||
4. Select your task (Core JS Promises) | ||
5. Press submit button and enjoy | ||
|
||
## Notes | ||
|
||
- We recommend you to use nodejs of version 16 or lower. If you using any of features that does not supported by node `v16`, score won't be submitted. | ||
- Installing nodejs `v16` is optional, you can run jobs using your version and not use methods that are not in nodejs `v16`. | ||
- Please be sure that each of your test in limit of 30sec. | ||
- You will get 0 (zero) if you have any eslint's errors or warnings. | ||
|
||
## FAQ | ||
|
||
**Question:** I use Windows machine and have received a lot of errors like "Expected linebreaks to be 'LF' but found 'CRLF'". How to handle it?<br> | ||
**Answer**: | ||
|
||
- First, you need to install Gitbash properly: you need to choose option "Checkout as-is, commit as-is" in section "Configuring the line ending conversions". It'll let you download repos with line endings set "as-is" as well as commit. In other words, not to change them at all, because by default it converts them. | ||
- Second, install `editorconfig` plugin to your editor. For VS Code you can find it here: | ||
https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig | ||
|
||
I'll let you apply some rules when you saving your files in the repo. This plugin will use config-file `.editorconfig` that you can see in the root folder. It lets you save the file with needed line endings, trim whitespaces, etc. | ||
|
||
- Finally, you need to apply linter's autofix feature in order to fix all linebreaks that was already changed to "CLRF": | ||
|
||
``` | ||
$ npm run lint:fix | ||
``` | ||
|
||
**Question:** Execution of tests "hangs" on one of them and does not display the result. What to do?<br> | ||
**Answer**: Check your solution for an infinite loop, fix it, and rerun the test. | ||
|
||
**Question:** The solution in the local repository succeeds and all tests are "green", but in the application some tests don't count. What to do?<br> | ||
**Answer**: [Update your repository fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork), update the local repository from the fork, run tests and fix your solution. After fixing, resubmit your solution for testing. | ||
|
||
--- | ||
|
||
The task based on https://github.com/mikhama/core-js-101/blob/master/src/06-promises-tasks.js |
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 @@ | ||
function isCommented(fn) { | ||
return /\/\/|\*(?=\/)/g.test(fn.toString()); | ||
} | ||
module.exports = { | ||
isCommented, | ||
}; |
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,29 @@ | ||
function testOptional(title, fn, isAsyncTest) { | ||
if (isAsyncTest) { | ||
it(title, function test(done) { | ||
try { | ||
fn.call(this, done); | ||
} catch (err) { | ||
if (err.message === 'Not implemented') { | ||
this.test.skip(); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
}); | ||
} else { | ||
it(title, function test() { | ||
try { | ||
fn.call(this); | ||
} catch (err) { | ||
if (err.message === 'Not implemented') { | ||
this.test.skip(); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
||
module.exports = testOptional; |
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,30 @@ | ||
{ | ||
"name": "core-js-promises", | ||
"version": "1.0.0", | ||
"description": "Core JS promises task", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "npm run lint && mocha", | ||
"lint": "node node_modules/eslint/bin/eslint.js ./src", | ||
"lint:fix": "node node_modules/eslint/bin/eslint.js ./src --fix" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rolling-scopes-school/core-js-promises.git" | ||
}, | ||
"author": "mikaleinik", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"eslint": "^8.53.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"mocha": "^10.2.0", | ||
"prettier": "^3.0.3" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/rolling-scopes-school/core-js-promises/issues" | ||
}, | ||
"homepage": "https://github.com/rolling-scopes-school/core-js-promises#readme" | ||
} |
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 @@ | ||
/** ******************************************************************************************** | ||
* * | ||
* Please read the following tutorial before implementing tasks: * | ||
* * | ||
********************************************************************************************* */ | ||
|
||
module.exports = {}; |
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,8 @@ | ||
const assert = require('assert'); | ||
const tasks = require('../src/core-js-promises-tasks'); | ||
const forbidden = require('../extensions/forbidden'); | ||
it.optional = require('../extensions/it-optional'); | ||
|
||
describe('core-js-promises', () => { | ||
it.optional('', () => {}); | ||
}); |