Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use ESLint & Prettier instead of jshint #1593

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
es6: true,
},
parserOptions: {
parser: '@typescript-eslint/parser',
ecmaVersion: 2020,
sourceType: 'module',
lib: ['es2020'],
},
plugins: ['prettier', 'jsdoc', 'security', '@typescript-eslint'],
extends: [
'prettier',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:jsdoc/recommended',
'plugin:security/recommended',
'plugin:prettier/recommended',
],
// add your custom rules here
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
},
};
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: ci

on:
push:
branches:
- main
- master
- dev
pull_request_target:
branches:
- main
- master
- dev

permissions:
checks: write
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
ci:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [16, 17]

steps:
- name: Check out repository (push)
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request_target' || github.event_name == 'pull_request' && github.actor != 'dependabot[bot]' }}
uses: actions/checkout@v2

- name: Check out repository (pull_request_target)
if: ${{ github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]' }}
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup node env πŸ“¦
uses: actions/setup-node@v2.5.1
with:
node-version: ${{ matrix.node }}
check-latest: true
registry-url: https://registry.npmjs.org
cache: 'npm'

- name: Upgrade npm ✨
run: npm i -g npm@latest

- name: Install dependencies πŸš€
run: npm ci --prefer-offline --no-audit

- name: Run linter(s) πŸ‘€
uses: wearerequired/lint-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
git_name: github-actions[bot]
git_email: github-actions[bot]@users.noreply.github.com
continue_on_error: false
auto_fix: true
neutral_check_on_warning: true
eslint: true
eslint_extensions: js,ts
prettier: true
prettier_extensions: js,ts
3 changes: 0 additions & 3 deletions .jshintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .jshintrc

This file was deleted.

16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@
"ciao": "node node_modules/ciao/bin/ciao -c test/ciao.json test/ciao",
"coverage": "node_modules/.bin/istanbul cover test/unit/run.js",
"docs": "./bin/generate-docs",
"lint": "jshint .",
"lint": "npm run lint:eslint && npm run lint:prettier",
"lintfix": "npm run lint:eslint:fix && npm run lint:prettier:fix",
"lint:js": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore",
"lint:eslint:fix": "eslint --fix \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore",
"lint:prettier": "prettier --check \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore",
"lint:prettier:fix": "prettier --write \"{,!(node_modules|dist|static)/**/}*.{js,ts}\" --ignore-path .gitignore",
"start": "./bin/start",
"test": "npm run unit",
"ci": "npm test",
Expand Down Expand Up @@ -67,12 +73,20 @@
"through2": "^3.0.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.9.0",
"@typescript-eslint/parser": "^5.9.0",
"ciao": "^2.0.0",
"difflet": "^1.0.1",
"eslint": "^8.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jsdoc": "^37.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-security": "^1.4.0",
"istanbul": "^0.4.2",
"jshint": "^2.10.1",
"pelias-mock-logger": "^1.3.0",
"precommit-hook": "^3.0.0",
"prettier": "^2.5.1",
"proxyquire": "^2.0.0",
"tap-dot": "^2.0.0",
"tape": "^5.1.1"
Expand Down
13 changes: 13 additions & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
$schema: 'http://json.schemastore.org/prettierrc',
semi: true,
arrowParens: 'always',
singleQuote: true,
trailingComma: 'all',
bracketSpacing: true,
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
tabWidth: 2,
useTabs: false,
endOfLine: 'lf',
};