Skip to content

Commit 3b22c8d

Browse files
author
Luke Karrys
authored
feat: port lint script from @npmcli/lint (#8)
* feat: port lint script from `@npmcli/lint` * chore: use @npmcli/template-oss
1 parent ce222e0 commit 3b22c8d

17 files changed

+397
-28
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
const { readdirSync: readdir } = require('fs')
4+
5+
const localConfigs = readdir(__dirname)
6+
.filter((file) => file.startsWith('.eslintrc.local.'))
7+
.map((file) => `./${file}`)
8+
9+
module.exports = {
10+
extends: [
11+
'@npmcli',
12+
...localConfigs,
13+
],
14+
}

.eslintrc.local.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["./lib/index.js"]
3+
}

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @npm/cli-team

.github/ISSUE_TEMPLATE/bug.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
name: Bug
4+
description: File a bug/issue
5+
title: "[BUG] <title>"
6+
labels: [Bug, Needs Triage]
7+
body:
8+
- type: checkboxes
9+
attributes:
10+
label: Is there an existing issue for this?
11+
description: Please [search here](./issues) to see if an issue already exists for your problem.
12+
options:
13+
- label: I have searched the existing issues
14+
required: true
15+
- type: textarea
16+
attributes:
17+
label: Current Behavior
18+
description: A clear & concise description of what you're experiencing.
19+
validations:
20+
required: false
21+
- type: textarea
22+
attributes:
23+
label: Expected Behavior
24+
description: A clear & concise description of what you expected to happen.
25+
validations:
26+
required: false
27+
- type: textarea
28+
attributes:
29+
label: Steps To Reproduce
30+
description: Steps to reproduce the behavior.
31+
value: |
32+
1. In this environment...
33+
2. With this config...
34+
3. Run '...'
35+
4. See error...
36+
validations:
37+
required: false
38+
- type: textarea
39+
attributes:
40+
label: Environment
41+
description: |
42+
examples:
43+
- **npm**: 7.6.3
44+
- **Node**: 13.14.0
45+
- **OS**: Ubuntu 20.04
46+
- **platform**: Macbook Pro
47+
value: |
48+
- npm:
49+
- Node:
50+
- OS:
51+
- platform:
52+
validations:
53+
required: false
54+

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
3+
blank_issues_enabled: true

.github/workflows/ci.yml

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
13
name: CI
24

35
on:
@@ -8,33 +10,45 @@ on:
810
- latest
911

1012
jobs:
11-
build:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-node@v2
18+
with:
19+
node-version: '16'
20+
cache: npm
21+
- run: npm i --prefer-online -g npm@latest
22+
- run: npm ci
23+
- run: npm run lint
24+
25+
test:
1226
strategy:
1327
fail-fast: false
1428
matrix:
15-
node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.x]
29+
node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x]
1630
platform:
1731
- os: ubuntu-latest
1832
shell: bash
1933
- os: macos-latest
2034
shell: bash
2135
- os: windows-latest
2236
shell: bash
37+
- os: windows-latest
38+
shell: cmd
2339
- os: windows-latest
2440
shell: powershell
25-
2641
runs-on: ${{ matrix.platform.os }}
2742
defaults:
2843
run:
2944
shell: ${{ matrix.platform.shell }}
30-
3145
steps:
3246
- uses: actions/checkout@v2
3347
- uses: actions/setup-node@v2
3448
with:
35-
cache: npm
3649
node-version: ${{ matrix.node-version }}
50+
cache: npm
3751
- run: npm i --prefer-online -g npm@latest
3852
- run: npm ci
39-
- run: npm test
53+
- run: npm test --ignore-scripts
4054
- run: npm ls -a

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
# This file is automatically added by @npmcli/template-oss. Do not edit.
2+
13
# ignore everything in the root
24
/*
35

46
# keep these
7+
!/.eslintrc*
58
!/.github
69
!**/.gitignore
710
!/package.json
@@ -13,3 +16,4 @@
1316
!/test
1417
!/README*
1518
!/LICENSE*
19+
!/SECURITY*

LICENSE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
2+
13
ISC License
24

35
Copyright npm, Inc.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,13 @@ module.exports = {
2626

2727
This allows any overrides for a project to exist in a separate file, typically
2828
`.eslintrc.local.json`.
29+
30+
#### `bin`
31+
32+
This module also contains a bin script that will run `eslint` with the bundled config.
33+
34+
```
35+
npm i -D @npmcli/eslint-config
36+
37+
# lint with our style rules
38+
npx @npmcli/eslint-config -- # any args to eslint go here...`

SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->
2+
3+
Please send vulnerability reports through [hackerone](https://hackerone.com/github).

bin/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env node
2+
3+
const { spawnSync } = require('child_process')
4+
const { sync: whichSync } = require('which')
5+
const { resolve } = require('path')
6+
const eslintrc = resolve(__dirname, '../lib/index.js')
7+
const args = ['-c', eslintrc, ...process.argv.slice(2)]
8+
const result = spawnSync(whichSync('eslint'), args, { stdio: 'inherit' })
9+
process.exitCode = result.exitCode

lib/index.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ module.exports = {
22
parserOptions: {
33
ecmaVersion: 2018,
44
ecmaFeatures: {},
5-
sourceType: 'script'
5+
sourceType: 'script',
66
},
77
env: {
88
es6: true,
9-
node: true
9+
node: true,
1010
},
1111
plugins: [
1212
'node',
1313
],
1414
globals: {
1515
document: 'readonly',
1616
navigator: 'readonly',
17-
window: 'readonly'
17+
window: 'readonly',
1818
},
1919
rules: {
2020
'accessor-pairs': 'error',
@@ -28,7 +28,7 @@ module.exports = {
2828
objects: 'always-multiline',
2929
imports: 'always-multiline',
3030
exports: 'always-multiline',
31-
functions: 'never'
31+
functions: 'never',
3232
}],
3333
'comma-spacing': ['error', { before: false, after: true }],
3434
'comma-style': ['error', 'last'],
@@ -41,7 +41,7 @@ module.exports = {
4141
eqeqeq: ['error', 'always', { null: 'ignore' }],
4242
'func-call-spacing': ['error', 'never'],
4343
'generator-star-spacing': ['error', { before: true, after: true }],
44-
'handle-callback-err': ['error', '^(err|error)$' ],
44+
'handle-callback-err': ['error', '^(err|error)$'],
4545
indent: ['error', 2, {
4646
SwitchCase: 1,
4747
VariableDeclarator: 1,
@@ -55,7 +55,7 @@ module.exports = {
5555
ImportDeclaration: 1,
5656
flatTernaryExpressions: true,
5757
ignoreComments: false,
58-
ignoredNodes: ['TemplateLiteral *']
58+
ignoredNodes: ['TemplateLiteral *'],
5959
}],
6060
'key-spacing': ['error', { beforeColon: false, afterColon: true }],
6161
'keyword-spacing': ['error', { before: true, after: true }],
@@ -139,7 +139,9 @@ module.exports = {
139139
'no-unreachable': 'error',
140140
'no-unsafe-finally': 0,
141141
'no-unsafe-negation': 'error',
142-
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
142+
'no-unused-expressions': ['error', {
143+
allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true,
144+
}],
143145
'no-unused-vars': ['error', { vars: 'all', args: 'none', ignoreRestSiblings: true }],
144146
'no-use-before-define': ['error', { functions: false, classes: false, variables: false }],
145147
'no-useless-call': 'error',
@@ -158,7 +160,7 @@ module.exports = {
158160
'one-var': ['error', { initialized: 'never' }],
159161
'operator-linebreak': 'off',
160162
'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
161-
'prefer-const': ['error', { destructuring: 'all'} ],
163+
'prefer-const': ['error', { destructuring: 'all' }],
162164
'prefer-promise-reject-errors': 'error',
163165
'quote-props': ['error', 'as-needed'],
164166
quotes: ['error', 'single', { avoidEscape: true, allowTemplateLiterals: true }],
@@ -172,7 +174,11 @@ module.exports = {
172174
'space-unary-ops': ['error', { words: true, nonwords: false }],
173175
'spaced-comment': ['error', 'always', {
174176
line: { markers: ['*package', '!', '/', ',', '='] },
175-
block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
177+
block: {
178+
balanced: true,
179+
markers: ['*package', '!', ',', ':', '::', 'flow-include'],
180+
exceptions: ['*'],
181+
},
176182
}],
177183
'symbol-description': 'error',
178184
'template-curly-spacing': ['error', 'never'],
@@ -188,5 +194,5 @@ module.exports = {
188194
'node/no-deprecated-api': 'error',
189195
'node/process-exit-as-throw': 'error',
190196
'node/no-callback-literal': 'error',
191-
}
197+
},
192198
}

0 commit comments

Comments
 (0)