Skip to content

Commit f0f30a2

Browse files
committed
Re-add prettier
- Re-add prettier as completely separate - Remove stylist as part of the linter - jsonc formatting for required files - Formatting markdown as well! - Added formatting and pre-commit to github actions
1 parent 3d3a5f0 commit f0f30a2

File tree

11 files changed

+97
-347
lines changed

11 files changed

+97
-347
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ dist/
55
.vscode/
66
node_modules/
77
coverage/
8+
report/
89
!*.js
910
!*.ts
1011
!.vscode/*.json
12+
package-lock.json

.github/workflows/main.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
name: Node.js CI
22

3-
on: [push]
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
47

58
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v4
14+
with:
15+
cache: 'pip'
16+
- uses: pre-commit/[email protected]
17+
618
build:
719
runs-on: ubuntu-latest
820

921
strategy:
1022
matrix:
11-
# Current versions not in maintainance
1223
node-version: [18.x, 20.x]
1324

1425
steps:
@@ -21,5 +32,6 @@ jobs:
2132
- run: npm ci
2233
- run: npm test
2334
- run: npm run lint
35+
- run: npm run format
2436
- run: npm run build:debug
2537
- run: npm run build:prod

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ repos: #The order matters, we want prospector to run after all the sorting was d
1919
# File normalization
2020
- id: end-of-file-fixer
2121
- id: trailing-whitespace
22+
- repo: https://github.com/pre-commit/mirrors-prettier
23+
rev: 'v3.1.0' # Use the sha or tag you want to point at
24+
hooks:
25+
- id: prettier

.prettierignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/.git
2+
**/.svn
3+
**/.hg
4+
**/node_modules
5+
package-lock.json
6+
lib/
7+
build/
8+
build-*/
9+
dist/
10+
.vscode/
11+
node_modules/
12+
coverage/
13+
report/
14+
!*.js
15+
!*.ts
16+
!.vscode/*.json

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
45
"ghmcadams.lintlens",
56
"visualstudioexptteam.vscodeintellicode",
67
"wix.vscode-import-cost",

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"typescriptreact"
55
],
66
"editor.formatOnSave": true,
7-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
7+
"editor.defaultFormatter": "esbenp.prettier-vscode",
88
"editor.codeActionsOnSave": {
99
"source.organizeImports": "never"
1010
},
1111
"[javascript,typescript]": {
12-
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
12+
"editor.defaultFormatter": "esbenp.prettier-vscode",
1313
"editor.codeActionsOnSave": {
1414
"source.organizeImports": "never"
1515
},

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
Example of typescript, eslint, and jest with property based testing.
44

5-
Possibly, you might want to delete the `.pre-commit-config.yaml` file if you are not using python anywhere.
6-
7-
This is only tested with certain versions of node and npm, it might work with others, disable the `engine-strict=true` in the `.npmrc` file at your discretion.
5+
Possibly, you might want to delete the `.pre-commit-config.yaml` file if you are
6+
not using python anywhere.
87

8+
This is only tested with certain versions of node and npm, it might work with
9+
others, disable the `engine-strict=true` in the `.npmrc` file at your
10+
discretion.
911

1012
## Check upgrades
1113

eslint.config.js

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
const stylistic = require('@stylistic/eslint-plugin');
21
const js = require('@eslint/js');
32
const tseslint = require('typescript-eslint');
4-
5-
const ts = require('@typescript-eslint/eslint-plugin');
3+
const eslintConfigPrettier = require('eslint-config-prettier');
64
const tsParser = require('@typescript-eslint/parser');
75
// When it works again do `npm install --save-dev eslint-plugin-import`
86
// const imprt = require('eslint-plugin-import');
97
// https://github.com/eslint/eslint/issues/18087
108
// https://github.com/import-js/eslint-plugin-import/pull/2829
119
const globals = require('globals');
1210
const jest = require('eslint-plugin-jest');
13-
const off = 'off';
1411

12+
const off = 'off';
1513
const warn = 'warn';
16-
1714
const error = 'error';
1815

1916
// const TEST_ONLY_IMPORTS = ['fast-check', 'jest'];
@@ -37,7 +34,9 @@ const any_rules = (level) => {
3734

3835
module.exports = [
3936
js.configs.recommended,
37+
tseslint.configs.eslintRecommended,
4038
...tseslint.configs.recommended,
39+
...tseslint.configs.recommendedTypeChecked,
4140
{
4241
languageOptions: {
4342
globals: globals.node,
@@ -54,19 +53,6 @@ module.exports = [
5453
},
5554
},
5655
},
57-
stylistic.configs['recommended-flat'],
58-
stylistic.configs.customize({
59-
// the following options are the default values
60-
semi: true,
61-
}),
62-
{
63-
languageOptions: { parser: tsParser },
64-
plugins: {
65-
// 'import': imprt,
66-
'@stylistic': stylistic,
67-
ts,
68-
},
69-
},
7056
{
7157
ignores: [
7258
'**/node_modules',
@@ -78,11 +64,10 @@ module.exports = [
7864
'**/report',
7965
],
8066
},
67+
// Disables all styling from eslint
68+
eslintConfigPrettier,
8169
{
8270
rules: {
83-
...ts.configs['eslint-recommended'].rules,
84-
...ts.configs['recommended'].rules,
85-
...ts.configs['recommended-requiring-type-checking'].rules,
8671
// ...imprt.configs['errors'].rules,
8772
// ...imprt.configs['warnings'].rules,
8873
// ...imprt.configs['typescript'].rules,
@@ -91,7 +76,7 @@ module.exports = [
9176
'@typescript-eslint/return-await': ['error', 'always'],
9277
'no-unused-vars': off,
9378
'@typescript-eslint/no-unused-vars': error,
94-
'eqeqeq': [error, 'smart'],
79+
eqeqeq: [error, 'smart'],
9580
'no-else-return': [
9681
error,
9782
{

0 commit comments

Comments
 (0)