Skip to content

Commit

Permalink
Update linting to use helix rules and setup workflows to test (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlpauls authored Feb 7, 2024
1 parent e7ff4ba commit 106bc38
Show file tree
Hide file tree
Showing 11 changed files with 1,446 additions and 1,320 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.vscode/*
coverage/*
dist/*
!.releaserc.js
test/*
59 changes: 13 additions & 46 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,52 +1,19 @@
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

module.exports = {
root: true,
extends: 'airbnb-base',
env: { browser: true, mocha: true },
parser: '@babel/eslint-parser',
parserOptions: {
allowImportExportEverywhere: true,
sourceType: 'module',
requireConfigFile: false,
},
extends: '@adobe/helix',
rules: {
'no-param-reassign': [2, { props: false }],
'linebreak-style': ['error', 'unix'],
'import/extensions': ['error', { js: 'always' }],
'object-curly-newline': ['error', {
ObjectExpression: { multiline: true, minProperties: 6 },
ObjectPattern: { multiline: true, minProperties: 6 },
ImportDeclaration: { multiline: true, minProperties: 6 },
ExportDeclaration: { multiline: true, minProperties: 6 },
}],
'no-await-in-loop': 0,
'class-methods-use-this': 0,
'no-return-assign': ['error', 'except-parens'],
'no-unused-expressions': 0,
'chai-friendly/no-unused-expressions': 2,
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message: 'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message: 'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
},
overrides: [
{
files: ['test/**/*.js'],
rules: { 'no-console': 'off' },
},
],
plugins: [
'chai-friendly',
],
};
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/install-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Install, lint, and test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
run-tests:
name: Running tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm ci

- name: Lint the code
run: npm run lint

- name: Run the tests
run: npm test
14 changes: 0 additions & 14 deletions .github/workflows/main.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

junit

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

Expand Down
6 changes: 4 additions & 2 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"reporter": [
"lcov",
"text"
"text",
"text-summary"
],
"check-coverage": true,
"lines": 10,
"branches": 10,
"statements": 10
"statements": 10,
"skip-full": true
}
Loading

0 comments on commit 106bc38

Please sign in to comment.