Skip to content

Commit 3b741a0

Browse files
authored
[PTP-939] chore: add linting policy (#359)
* chore: add linting policy * fix: ci * fix: no unused vars rule * fix: eslint errors
1 parent 7967c6c commit 3b741a0

File tree

53 files changed

+6208
-4813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6208
-4813
lines changed

.editorconfig

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
[*]
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
charset = utf-8
11+
trim_trailing_whitespace = true
12+
insert_final_newline = true

.eslintrc

+14-7
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
"no-wildcard-postmessage",
88
"react"
99
],
10-
"parser": "babel-eslint",
10+
"parser": "@typescript-eslint/parser",
1111
"extends": [
12-
"standard",
13-
"standard-react",
1412
"plugin:prettier/recommended",
15-
"prettier/standard",
16-
"prettier/react",
17-
"plugin:security/recommended"
13+
"plugin:security/recommended",
14+
"plugin:@typescript-eslint/recommended",
15+
"plugin:import/typescript"
1816
],
1917
"env" : {
2018
"browser" : true,
@@ -36,7 +34,16 @@
3634
"space-before-function-paren": 0,
3735

3836
"import/export": 0,
39-
"indent": ["error", 4, { "ignoredNodes": ["ConditionalExpression"] }],
37+
"@typescript-eslint/no-var-requires": "off",
38+
"@typescript-eslint/ban-ts-comment": "off",
39+
"@typescript-eslint/no-unused-vars": [
40+
"error",
41+
{
42+
"argsIgnorePattern": "^_",
43+
"varsIgnorePattern": "^_"
44+
}
45+
],
46+
"@typescript-eslint/no-explicit-any": "warn",
4047
/** ScanJS rules **/
4148
"scanjs-rules/accidental_assignment": 1,
4249
"scanjs-rules/assign_to_hostname" : 1,

.github/workflows/ci.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
ci:
7+
if: ${{ contains(github.event.head_commit.message, '[run ci]') || github.event_name == 'pull_request' }}
8+
runs-on: ubuntu-latest
9+
10+
env:
11+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
18+
- name: Saving cache
19+
uses: actions/cache@v2
20+
with:
21+
path: '**/node_modules'
22+
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
23+
24+
- name: Set up Node
25+
uses: actions/setup-node@v1
26+
with:
27+
node-version: 18
28+
registry-url: 'https://npm.pkg.github.com'
29+
30+
- name: Install dependencies
31+
run: |
32+
npm install
33+
34+
- name: Check linting
35+
run: npm run lint:eslint
36+
37+
- name: Check TS
38+
run: npm run check-ts
39+
40+
# - name: Check tests
41+
# run: |
42+
# npm run test

.husky/pre-commit

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged && npm run check-ts

.prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"bracketSameLine": true,
3+
"bracketSpacing": true,
4+
"singleQuote": true,
5+
"trailingComma": "all",
6+
"arrowParens": "avoid",
7+
"semi": true,
8+
"printWidth": 100
9+
}

karma-variables.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
12
const process = {
2-
env: {
3-
APP_ID: 'IDmESP4jtv5BH15NTPdz8SGk',
4-
BUILD_ENV: 'dev',
5-
ENV: "partner",
6-
STAGE: "stage",
7-
TARGET_MODE: "targetMode",
8-
}
3+
env: {
4+
APP_ID: 'IDmESP4jtv5BH15NTPdz8SGk',
5+
BUILD_ENV: 'dev',
6+
ENV: 'partner',
7+
STAGE: 'stage',
8+
TARGET_MODE: 'targetMode',
9+
},
910
};

karma.conf.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
21
const { createDefaultConfig } = require('@open-wc/testing-karma');
32
const merge = require('deepmerge');
43

@@ -16,8 +15,8 @@ module.exports = config => {
1615
reporters: [
1716
{ type: 'html', subdir: 'report-html' },
1817
{ type: 'text', subdir: '.' },
19-
{ type: 'lcov', subdir: '.' }
20-
]
18+
{ type: 'lcov', subdir: '.' },
19+
],
2120
},
2221
plugins: [
2322
// load plugin
@@ -41,9 +40,8 @@ module.exports = config => {
4140
statements: 50,
4241
branches: 30,
4342
functions: 50,
44-
lines: 50
45-
}
46-
43+
lines: 50,
44+
},
4745
}),
4846
);
4947
return config;

0 commit comments

Comments
 (0)