This repository has been archived by the owner on Nov 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code style/formatting: Prettier + Airbnb ESLint preset (#146)
The purpose of this change is to move toward a more idiomatic code style, and automate as much of it as possible. What's in the change: - Adds automatic formatting provided by [Prettier](https://prettier.io/) - Consolidates all ESLint configs into one file via `overrides` - Extends [Airbnb's ESLint config](https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb), a commonly used, opinionated set of rules - Overrides some of those rules to be warnings where they're not automatically fixable; there are _a lot of warnings_, the goal is to fix them wherever we touch code with warnings - Manually fixes a very small portion of those warnings where it was trivial and obviously safe - Extends Prettier's ESLint config to enable checking Prettier rules (e.g. while editing in VSCode and in CI) - Applies automatic Prettier and ESLint formatting on save in VSCode I've validated that transforms behave the same before and after this change, with all of the forms under test/forms as well as those from Enketo Core.
- Loading branch information
1 parent
9b2e08d
commit b3c8d07
Showing
27 changed files
with
5,099 additions
and
2,819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
name: npmjs | ||
|
||
on: | ||
push: | ||
pull_request: | ||
release: | ||
types: | ||
- published | ||
push: | ||
pull_request: | ||
release: | ||
types: | ||
- published | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: [ '14', '16' ] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: node_modules | ||
key: ${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install -g npm@^6 | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
- run: npm test | ||
- run: npm run build-docs | ||
- if: github.event_name == 'release' && github.event.action == 'published' && matrix.node == '16' | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node: ['14', '16'] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: node_modules | ||
key: ${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm install -g npm@^6 | ||
- if: steps.cache.outputs.cache-hit != 'true' | ||
run: npm ci | ||
- run: npm test | ||
- run: npm run build-docs | ||
- if: github.event_name == 'release' && github.event.action == 'published' && matrix.node == '16' | ||
run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Ignore artifacts: | ||
|
||
.nyc* | ||
*/node_modules/* | ||
docs/* | ||
test-coverage/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/prettierrc", | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
{ | ||
// Formatting | ||
"eslint.enable": true, | ||
"eslint.options": { | ||
"rules": { | ||
"no-debugger": 1 // Warn rather than error in-editor | ||
} | ||
"extends": ["../.eslintrc.json"] | ||
}, | ||
"eslint.nodePath": "../node_modules/.bin", | ||
"eslint.validate": ["markdown", "md"], | ||
"prettier.configPath": ".prettierrc.json", | ||
"prettier.ignorePath": ".prettierignore", | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.codeActionsOnSave": [ | ||
"source.formatDocument", | ||
"source.fixAll.eslint" | ||
], | ||
"editor.formatOnSave": true, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode", | ||
"editor.formatOnSave": true | ||
}, | ||
|
||
// Code navigation | ||
"javascript.referencesCodeLens.enabled": true | ||
} |
Oops, something went wrong.