Skip to content

Commit 79c12ff

Browse files
committed
add javascript basic starter
1 parent 248f910 commit 79c12ff

26 files changed

+12580
-1
lines changed

.eslintrc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"browser": true,
5+
"node": true
6+
},
7+
"plugins": [
8+
"eslint-plugin-html",
9+
"simple-import-sort",
10+
"import"
11+
],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:prettier/recommended"
15+
],
16+
"rules": {
17+
"no-var": "error",
18+
"object-shorthand": "error",
19+
"prefer-const": "error",
20+
"prefer-template": "error",
21+
"prefer-destructuring": "warn",
22+
"prefer-rest-params": "warn",
23+
"prefer-spread": "warn",
24+
"yoda": "error",
25+
"simple-import-sort/imports": "error",
26+
"simple-import-sort/exports": "error",
27+
"import/first": "error",
28+
"import/newline-after-import": "error",
29+
"import/no-duplicates": "error"
30+
}
31+
}

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: lint
2+
3+
on: push
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Cache node modules
13+
uses: actions/cache@v2
14+
env:
15+
cache-name: cache-node-modules
16+
with:
17+
path: ~/.npm
18+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
19+
restore-keys: |
20+
${{ runner.os }}-build-${{ env.cache-name }}-
21+
${{ runner.os }}-build-
22+
${{ runner.os }}-
23+
24+
- name: Install Dependencies
25+
run: npm install
26+
27+
- name: Lint
28+
run: npm run lint

.github/workflows/test.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: test
2+
3+
on: push
4+
5+
jobs:
6+
unit:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
12+
- name: Cache node modules
13+
uses: actions/cache@v2
14+
env:
15+
cache-name: cache-node-modules
16+
with:
17+
path: ~/.npm
18+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
19+
restore-keys: |
20+
${{ runner.os }}-build-${{ env.cache-name }}-
21+
${{ runner.os }}-build-
22+
${{ runner.os }}-
23+
24+
- name: Install Dependencies
25+
run: npm install
26+
27+
- name: Test
28+
run: npm run test
29+
e2e:
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v2
34+
35+
- name: Cache node modules
36+
uses: actions/cache@v2
37+
env:
38+
cache-name: cache-node-modules
39+
with:
40+
path: ~/.npm
41+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
42+
restore-keys: |
43+
${{ runner.os }}-build-${{ env.cache-name }}-
44+
${{ runner.os }}-build-
45+
${{ runner.os }}-
46+
47+
- name: Install Dependencies
48+
run: npm install
49+
50+
- name: Cypress run
51+
uses: cypress-io/github-action@v2
52+
with:
53+
build: npm run build
54+
start: npm run start
55+
wait-on: "http://localhost:8080"

.prettierrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,64 @@
1-
# javascript-basic-skeleton
1+
# JavaScript Bootstrap (base / project starter)
2+
3+
This is a repository intended to serve as a starting point if you want to bootstrap a project in modern vanilla JavaScript.
4+
5+
## Features
6+
7+
- [Webpack](https://webpack.js.org/) (v5)
8+
- [Babel](https://babeljs.io/) with [preset-env](https://babeljs.io/docs/en/babel-preset-env)
9+
- [Prettier](https://prettier.io/)
10+
- [ESLint](https://eslint.org/) with:
11+
- [Simple Import Sort](https://github.com/lydell/eslint-plugin-simple-import-sort/)
12+
- [Import plugin](https://github.com/benmosher/eslint-plugin-import/)
13+
- [HTML plugin](https://github.com/BenoitZugmeyer/eslint-plugin-html)
14+
- And a few other ES2015+ related rules
15+
- [Jest](https://jestjs.io) with [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro)
16+
- [Cypress](https://www.cypress.io/) with [Testing Library](https://testing-library.com/docs/cypress-testing-library/)
17+
- [GitHub Action workflows](https://github.com/features/actions) set up to run tests and linting on push
18+
19+
## Running the app
20+
21+
```
22+
# install dependencies
23+
npm install
24+
25+
# run in dev mode on port 8080
26+
npm run dev
27+
28+
# generate production build
29+
npm run build
30+
31+
# run generated content in dist folder on port 8080
32+
npm run start
33+
```
34+
35+
## Testing
36+
37+
### Jest with Testing Library
38+
39+
```
40+
npm run test
41+
```
42+
43+
### Cypress
44+
45+
```
46+
# run in dev mode on port 8080
47+
npm run dev
48+
49+
# open Cypress to run tests on dev mode
50+
npm run cy:open
51+
52+
# open Cypress on CLI
53+
npm run cy:run
54+
```
55+
56+
## Linting
57+
58+
```
59+
# run linter
60+
npm run lint
61+
62+
# fix lint issues
63+
npm run lint:fix
64+
```

babel.config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"useBuiltIns": "usage",
7+
"corejs": "3.9.1"
8+
}
9+
]
10+
]
11+
}

cypress.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:8080",
3+
"video": false
4+
}

cypress/.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"plugins": [
3+
"cypress"
4+
],
5+
"extends": [
6+
"plugin:cypress/recommended"
7+
]
8+
}

cypress/fixtures/example.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "Using fixtures to represent data",
3+
"email": "hello@cypress.io",
4+
"body": "Fixtures are a great way to mock data for responses to routes"
5+
}

cypress/integration/home.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
describe("The Home Page", () => {
2+
it("successfully loads", () => {
3+
cy.visit("/");
4+
cy.findByRole("heading", { name: /hello world/i }).should("exist");
5+
});
6+
});

0 commit comments

Comments
 (0)