Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit f040593

Browse files
committed
Add eslint-config-node
1 parent 55aaaf2 commit f040593

26 files changed

+1450
-362
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
charset = utf-8
8+
max_line_length = 120
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintrc.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { overrides } = require('@netlify/eslint-config-node')
2+
3+
module.exports = {
4+
extends: '@netlify/eslint-config-node',
5+
rules: {
6+
// TODO: enable those rules
7+
'array-callback-return': 0,
8+
complexity: 0,
9+
'consistent-this': 0,
10+
'func-names': 0,
11+
'func-style': 0,
12+
'id-length': 0,
13+
'line-comment-position': 0,
14+
'max-nested-callbacks': 0,
15+
'max-statements': 0,
16+
'no-await-in-loop': 0,
17+
'no-inline-comments': 0,
18+
'no-magic-numbers': 0,
19+
'no-param-reassign': 0,
20+
'no-promise-executor-return': 0,
21+
'no-shadow': 0,
22+
'fp/no-class': 0,
23+
'fp/no-delete': 0,
24+
'fp/no-let': 0,
25+
'fp/no-loops': 0,
26+
'fp/no-mutating-assign': 0,
27+
'fp/no-mutating-methods': 0,
28+
'fp/no-mutation': 0,
29+
'fp/no-this': 0,
30+
'node/exports-style': 0,
31+
'node/global-require': 0,
32+
'node/prefer-global/process': 0,
33+
'promise/no-callback-in-promise': 0,
34+
'promise/prefer-await-to-callbacks': 0,
35+
'promise/prefer-await-to-then': 0,
36+
'unicorn/filename-case': 0,
37+
'you-dont-need-lodash-underscore/flatten': 0,
38+
},
39+
overrides: [...overrides],
40+
}

.eslintrc.json

Lines changed: 0 additions & 41 deletions
This file was deleted.

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/ISSUE_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Use the commands below to provide key information from your environment:
1616
You do NOT have to include this information if this is a FEATURE REQUEST
1717
-->
1818

19-
**- Do you want to request a *feature* or report a *bug*?**
19+
**- Do you want to request a _feature_ or report a _bug_?**
2020

2121
**- What is the current behavior?**
2222

.github/workflows/workflow.yml

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ on:
66
tags: ['*']
77
pull_request:
88
types: [opened, synchronize, reopened]
9-
env:
10-
CI: 'true'
119
jobs:
1210
build:
11+
runs-on: ${{ matrix.os }}
12+
timeout-minutes: 30
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest, macOS-latest, windows-latest]
16-
node-version: [8.3.0, 14]
16+
node-version: [8.17.0, 14.x]
1717
exclude:
1818
- os: macOS-latest
19-
node-version: 8.3.0
19+
node-version: 8.17.0
2020
- os: windows-latest
21-
node-version: 8.3.0
21+
node-version: 8.17.0
2222
fail-fast: false
23-
runs-on: ${{ matrix.os }}
2423
steps:
2524
- name: Git checkout
2625
uses: actions/checkout@v2
@@ -29,14 +28,24 @@ jobs:
2928
with:
3029
node-version: ${{ matrix.node-version }}
3130
- name: Install dependencies
32-
run: npm install
31+
run: npm ci
3332
- name: Linting
34-
run: npm run format
35-
if: "${{ matrix.node-version == '14' }}"
33+
run: npm run format:ci
34+
if: "${{ matrix.node-version == '14.x' }}"
3635
- name: Tests
3736
run: npm run test:ci
37+
- name: Get test coverage flags
38+
id: test-coverage-flags
39+
run: |-
40+
os=${{ matrix.os }}
41+
node=${{ matrix.node-version }}
42+
echo "::set-output name=os::${os/-latest/}"
43+
echo "::set-output name=node::node_${node//./}"
44+
shell: bash
45+
- uses: codecov/codecov-action@v1
46+
with:
47+
file: coverage/coverage-final.json
48+
flags: ${{ steps.test-coverage-flags.outputs.os }},${{ steps.test-coverage-flags.outputs.node }}
3849
- name: Build
3950
run: npm run build
40-
if: "${{ matrix.node-version == '14' }}"
41-
- name: Codecov test coverage
42-
run: bash scripts/coverage.sh "${{ matrix.os }}" "${{ matrix.node-version }}"
51+
if: "${{ matrix.node-version == '14.x' }}"

.prettierrc.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
{
2-
"semi": false,
3-
"singleQuote": true,
4-
"printWidth": 120
5-
}
1+
"@netlify/eslint-config-node/.prettierrc.json"

README.md

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,38 @@ A Netlify [OpenAPI](https://github.com/netlify/open-api) client that works in th
99

1010
```js
1111
const NetlifyAPI = require('netlify')
12-
const client = new NetlifyAPI('1234myAccessToken')
13-
const sites = await client.listSites()
12+
13+
const listNetlifySites = async function() {
14+
const client = new NetlifyAPI('1234myAccessToken')
15+
const sites = await client.listSites()
16+
return sites
17+
}
1418
```
1519

1620
## Using OpenAPI operations
1721

1822
```js
1923
const NetlifyAPI = require('netlify')
24+
2025
const client = new NetlifyAPI('1234myAccessToken')
2126

22-
// Fetch sites
23-
const sites = await client.listSites()
27+
const listCreateAndDeleteSite = async function() {
28+
// Fetch sites
29+
const sites = await client.listSites()
2430

25-
// Create a site. Notice `body` here for sending OpenAPI body
26-
const site = await client.createSite({
27-
body: {
28-
name: `my-awesome-site`,
29-
// ... https://open-api.netlify.com/#/default/createSite
30-
},
31-
})
31+
// Create a site. Notice `body` here for sending OpenAPI body
32+
const site = await client.createSite({
33+
body: {
34+
name: `my-awesome-site`,
35+
// ... https://open-api.netlify.com/#/default/createSite
36+
},
37+
})
3238

33-
// Delete site. Notice `site_id` is a path parameter https://open-api.netlify.com/#/default/deleteSite
34-
await client.deleteSite({
35-
site_id: siteId,
36-
})
39+
// Delete site. Notice `site_id` is a path parameter https://open-api.netlify.com/#/default/deleteSite
40+
await client.deleteSite({
41+
site_id: siteId,
42+
})
43+
}
3744
```
3845

3946
## API
@@ -47,7 +54,7 @@ Create a new instance of the Netlify API client with the provided `accessToken`.
4754
`opts` includes:
4855

4956
```js
50-
{
57+
const opts = {
5158
userAgent: 'netlify/js-client',
5259
scheme: 'https',
5360
host: 'api.netlify.com',
@@ -83,7 +90,7 @@ Performs a call to the given endpoint corresponding with the `operationId`. Retu
8390

8491
```js
8592
// example params
86-
{
93+
const params = {
8794
any_param_needed,
8895
paramsCanAlsoBeCamelCase,
8996
body: {
@@ -96,7 +103,7 @@ Optional `opts` can include any property you want passed to [`node-fetch`](https
96103

97104
```js
98105
// example opts
99-
{
106+
const opts = {
100107
headers: { // Default headers
101108
'User-agent': 'netlify-js-client',
102109
accept: 'application/json'
@@ -115,7 +122,7 @@ async function getSomeData() {
115122
siteId: '1234abcd',
116123
deploy_id: '4567',
117124
})
118-
} catch (e) {
125+
} catch (error) {
119126
// handle error
120127
}
121128
}
@@ -134,7 +141,7 @@ Pass in a [`ticket`](https://open-api.netlify.com/#model-ticket) and get back an
134141
Optional `opts` include:
135142

136143
```js
137-
{
144+
const opts = {
138145
poll: 1000, // number of ms to wait between polling
139146
timeout: 3.6e6 // number of ms to wait before timing out
140147
}
@@ -169,7 +176,7 @@ The following paths can be passed in the options:
169176
Optional `opts` include:
170177

171178
```js
172-
{
179+
const opts = {
173180
fnDir: null, // path to a folder of functions to deploy
174181
branch: null, // branch to pass onto the netlify api
175182
configPath: null, // path to a netlify.toml file to include in the deploy (e.g. redirect support for manual deploys)
@@ -183,17 +190,17 @@ Optional `opts` include:
183190
tmpDir: tempy.directory(), // a temporary directory to zip functions into
184191
statusCb: statusObj => {
185192
// a callback function to receive status events
186-
/* statusObj: {
187-
type: name-of-step
188-
msg: msg to print
189-
phase: [start, progress, stop]
190-
} */
193+
// statusObj: {
194+
// type: name-of-step
195+
// msg: msg to print
196+
// phase: [start, progress, stop]
197+
// }
191198
// See https://github.com/netlify/cli/blob/v2.0.0-beta.3/src/commands/deploy.js#L161-L195
192199
// for an example of how this can be used.
193200
},
194201
// passing a deployId will update an existing deploy based on the provided options
195202
deployId: null
196-
}
203+
}
197204
```
198205

199206
## Proxy support

ava.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)