Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: RickNln/exercises-javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: RickNln/exercises-javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
Loading
Showing 375 changed files with 7,061 additions and 3,213 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -3,10 +3,9 @@
extends:
- airbnb-base

parser: babel-eslint

env:
node: true
jest: true

rules:
import/no-unresolved: 0
48 changes: 28 additions & 20 deletions .github/workflows/Docker.yml
Original file line number Diff line number Diff line change
@@ -3,39 +3,47 @@ name: Docker
on:
push:
branches:
- master
- main
pull_request:
branches:
- main

env:
# TODO: Change variable to your image's name.
IMAGE_NAME: hexletbasics/exercises-javascript
# TODO: Change variable to your registry.
REGISTRY_NAME: hexletbasics

jobs:
# Run tests.
# See also https://docs.docker.com/docker-hub/builds/automated-testing/
test:
build-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run tests
run: |
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
# Push image to GitHub Package Registry.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test
docker-compose --file docker-compose.test.yml build
docker-compose --file docker-compose.test.yml run sut
build-push-notify:
runs-on: ubuntu-latest
if: github.event_name == 'push'

if: ${{ github.event_name == 'push' }}
needs: build-test
steps:
- uses: actions/checkout@master
- uses: elgohr/Publish-Docker-Github-Action@master
- uses: actions/checkout@v2
- name: Set repository name
run: |
echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" >> $GITHUB_ENV
- name: Build and push into docker hub
uses: docker/build-push-action@v1.1.0
with:
name: ${{ env.IMAGE_NAME }}
repository: ${{ env.REGISTRY_NAME }}/${{ env.REPOSITORY_NAME }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
tags: latest
- name: Set fail Slack env vars
if: ${{ failure() }}
run: |
echo "SLACK_COLOR=#a30200" >> $GITHUB_ENV
- name: Send notification into Slack
if: ${{ always() }}
uses: rtCamp/action-slack-notify@v2.0.0
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
18 changes: 6 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
FROM node:13.7

ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8

RUN apt-get update && apt-get install -yqq git python3-pip

RUN pip3 install yamllint
FROM hexletbasics/base-image

WORKDIR /exercises-javascript

COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm ci
COPY . .

ENV NODE_PATH /exercises-javascript/src

COPY . /exercises-javascript
RUN npm install -g npm-check-updates
RUN npm ci

ENV PATH=/exercises-javascript/bin:$PATH
37 changes: 10 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
-include /opt/basics/common/common.mk

compose-setup: compose-build compose-install

compose:
docker-compose up

gcloud-builds-submit:
gcloud builds submit --config cloudbuild.yaml .

compose-test:
docker-compose run exercises make test

compose-lint:
docker-compose run exercises make lint

compose-install:
docker-compose run exercises npm install

compose-bash:
docker-compose run exercises bash

compose-build:
docker-compose build

docker-release: docker-build docker-push

SUBDIRS := $(wildcard modules/**/*/.)
compose-install:
docker-compose run exercises npm ci

lint:
yamllint modules
code-lint:
npx eslint modules

test: $(SUBDIRS)
$(SUBDIRS):
@echo
# npm run test -s -- $@
make test -C $@
@echo
compose-bash:
docker-compose run exercises bash

.PHONY: all $(SUBDIRS)
compose-test:
docker-compose run exercises make test
52 changes: 30 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
[![Github Actions Status](https://github.com/hexlet-basics/exercises-javascript/workflows/Docker/badge.svg)](https://github.com/hexlet-basics/exercises-javascript/actions)

## Develop

```sh
# setup
$ make
# run
$ make compose

# run tests
$ make compose-test

# run linters
$ make compose-lint
```

##
[![Hexlet Ltd. logo](https://raw.githubusercontent.com/Hexlet/hexletguides.github.io/master/images/hexlet_logo128.png)](https://ru.hexlet.io/pages/about?utm_source=github&utm_medium=link&utm_campaign=exercises-javascript)

This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet (in Russian)](https://ru.hexlet.io/pages/about?utm_source=github&utm_medium=link&utm_campaign=exercises-javascript).
##
# hexlet-basics

[![Github Actions Status](../../workflows/Docker/badge.svg)](../../actions)

### Участие

* Обсуждение в канале #hexlet-volunteers слака http://slack-ru.hexlet.io

## Develop

```sh
# setup
$ make
# run
$ make compose

# run tests
$ make compose-test

# run linters and validators
$ make compose-code-lint
$ make compose-description-lint
$ make compose-schema-validate
```

##
[![Hexlet Ltd. logo](https://raw.githubusercontent.com/Hexlet/assets/master/images/hexlet_logo128.png)](https://ru.hexlet.io/pages/about?utm_source=github&utm_medium=link&utm_campaign=exercises-javascript)

This repository is created and maintained by the team and the community of Hexlet, an educational project. [Read more about Hexlet (in Russian)](https://ru.hexlet.io/pages/about?utm_source=github&utm_medium=link&utm_campaign=exercises-javascript).
##
2 changes: 2 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# npx -n --experimental-vm-modules jest --debug --runTestsByPath `pwd`/test.js --ci `pwd`
node `pwd`/test.js 2>&1
29 changes: 0 additions & 29 deletions cloudbuild.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ version: '2'
services:
sut:
build: .
command: make lint test
command: make check
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -7,4 +7,4 @@ services:
build: .
volumes:
- .:/exercises-javascript
command: make lint test
command: make check
2 changes: 1 addition & 1 deletion modules/10-basics/10-hello-world/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test:
node ./test.js 2>&1
@ test.sh
4 changes: 2 additions & 2 deletions modules/10-basics/10-hello-world/description.en.yml
Original file line number Diff line number Diff line change
@@ -8,15 +8,15 @@ theory: |
Hello, World!
</pre>
To display something on screen, you need to give computer a special command. In the JavaScript language the command is — `console.log`.
To display something on screen, you need to give computer a special command. In the JavaScript language the command is — `console.log()`.
instructions: |
Copy the exact code from the instructions into the editor and run it by pressing the “Submit” button.
```javascript
console.log('Hello, World!');
```
Note that if you type `hello, woRld!` instead of `Hello, World!`, it will be counted us an absolutely different text, because in JS capital and small letters are different symbols. Letter size is called _case_ and in programming the frase _case is important_ is frequently used. This rule affects almost everything in code so get used to pay close attention to case.
Note that if you type `hello, woRld!` instead of `Hello, World!`, it will be counted us an absolutely different text, because in JavaScript capital and small letters are different symbols. Letter size is called _case_ and in programming the frase _case is important_ is frequently used. This rule affects almost everything in code so get used to pay close attention to case.
tips:
- |
2 changes: 1 addition & 1 deletion modules/10-basics/10-hello-world/description.ru.yml
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ theory: |
Hello, World!
</pre>
Чтобы вывести что-то на экран, нужно дать компьютеру специальную команду. В языке JavaScript такая команда — `console.log`.
Чтобы вывести что-то на экран, нужно дать компьютеру специальную команду. В языке JavaScript такая команда — `console.log()`.
instructions: |
Наберите в редакторе код из задания символ в символ и нажмите «Проверить».
4 changes: 3 additions & 1 deletion modules/10-basics/10-hello-world/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { expectOutput } = require('tests');
// @ts-check

import { expectOutput } from 'hexlet-basics/tests';

const expected = 'Hello, World!';
expectOutput(expected);
2 changes: 1 addition & 1 deletion modules/10-basics/20-comments/Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
test:
node ./test.js 2>&1
@ test.sh
4 changes: 2 additions & 2 deletions modules/10-basics/20-comments/description.en.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

name: Comments
theory: |
Almost every programming language allows you to add comments to your code. Interpreter doesn't evaluate comments, their only purpose is to give programmers opportunity to leave notes for themselves and others. There are two types of comments in JS:
Almost every programming language allows you to add comments to your code. Interpreter doesn't evaluate comments, their only purpose is to give programmers opportunity to leave notes for themselves and others. There are two types of comments in JavaScript:
**Single line comments** start with `//`. Any text or symbols that follow, won't be evaluated or executed.
@@ -29,7 +29,7 @@ theory: |
```
instructions: |
Create a single line comment with the folowing text: `You know nothing, Jon Snow!`.
Create a single line comment with the following text: `You know nothing, Jon Snow!`.
tips: []

34 changes: 24 additions & 10 deletions modules/10-basics/20-comments/description.ru.yml
Original file line number Diff line number Diff line change
@@ -3,32 +3,46 @@
name: Комментарии
theory: |
Практически все языки программирования позволяют оставлять в коде комментарии. Они никак не используются интерпретатором и нужны исключительно для людей: чтобы программист оставлял пометки для себя и для других программистов. Комментарии в JavaScript бывают двух видов:
Кроме кода, в файлах с исходным кодом могут находиться комментарии. Это текст, который не является частью программы и нужен программистам для пометок. С их помощью добавляют пояснения, как работает код, какие здесь ошибки нужно поправить или не забыть что-то добавить позже.
```javascript
// Удалить строку ниже после реализации задачи по регистрации
console.log(10);
```
Комментарии в JavaScript бывают двух видов:
## Однострочные комментарии
_Однострочные комментарии_ начинаются с `//`. После этих двух символов может следовать любой текст, вся строчка не будет анализироваться и исполняться.
Комментарий может занимать всю строчку:
Комментарий может занимать всю строчку. Если одной строчки мало, то создаются несколько комментариев:
```javascript
// For Winterfell!
// For Lanisters!
```
или может находиться на строчке после какого-нибудь кода:
Комментарий может находиться на строчке после какого-нибудь кода:
```javascript
console.log('I am the King'); // For Lannisters!
```
_Многострочные комментарии_ начинаются с `/*` и заканчиваются на `*/`. Между ними каждая строчка должна начинаться с символа `*`.
## Многострочные комментарии
_Многострочные комментарии_ начинаются с `/*` и заканчиваются на `*/`.
```javascript
/*
* The night is dark and
* full of terrors.
*/
The night is dark and
full of terrors.
*/
console.log('I am the King');
```
Такие комментарии, обычно, используют для документирования кода, например, функций.
instructions: |
Создайте однострочный комментарий с текстом: `You know nothing, Jon Snow!`.
@@ -37,13 +51,13 @@ tips: []
definitions:
- name: Комментарий
description: |
Текст в коде программы, который не влияет на функциональность и добавляется программистами для себя и своих коллег.
текст в коде программы, который не влияет на функциональность и добавляется программистами для себя и своих коллег.
`// однострочный комментарий`
```
/*
* многострочный комментарий
* многострочный комментарий
многострочный комментарий
многострочный комментарий
*/
```
4 changes: 3 additions & 1 deletion modules/10-basics/20-comments/test.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require('.');
// @ts-check

import './index.js';
3 changes: 1 addition & 2 deletions modules/10-basics/40-instructions/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
test:
node ./test.js 2>&1

@ test.sh
Loading