-
Notifications
You must be signed in to change notification settings - Fork 585
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removing @typescript-eslint/eslint-recommended Since plugin:@typescript-eslint/recommended is already extending it. * Marking eslint configs as root * Removing unused tslint.json configurations * Using eslint in realm-intergration-tests * Reordering plugins in the config * Adding lerna: scripts to root package * Publishing realm-app-importer on the default repository * Adding a lint script to electron and node * Fixed trivial false-negatives * Ignoring the example packages * Creating a workflow to lint on PRs * Hoisting eslint to the root * Switched around name and run in workflow * Simplifying eslint configs by relying on cascading * A more default prettier config * Minor adjustments to the eslint configs * Updated header to match the copyright date as a pattern * Simplified eslintconfig in types * Upgraded to node v14 & npm v7 in workflows * Adding npm >= 7 to engines * Removed linting in the realm-web workflow * Minor change to the eslint configs * Don't use npm v7 on windows * Renamed job * Fixing eslint config errors * Adding a guide and vscode configuration files * Removed unwanted dependecies on tslint * Swapped if: and run: in workflow * Removed linting from test.sh and Jenkinsfile * Updated package-locks
- Loading branch information
1 parent
36944e8
commit 2e5819b
Showing
48 changed files
with
1,969 additions
and
1,999 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Linting (Pull Request) | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
# No need to run when updating documentation | ||
- '!**.md' | ||
|
||
jobs: | ||
lint: | ||
name: Lint | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 14 | ||
registry-url: https://registry.npmjs.org/ | ||
- name: Install npm v7 | ||
run: npm install -g npm@7 | ||
# Install the root package (--ignore-scripts to avoid downloading or building the native module) | ||
- name: Install root package dependencies | ||
run: npm ci --ignore-scripts | ||
- name: Install subpackages dependencies | ||
run: npm run lerna:bootstrap | ||
- name: Run linting of subpackages | ||
run: npm run lerna:lint -- --no-bail --concurrency 1 --stream --no-prefix |
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
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,7 +1,4 @@ | ||
module.exports = { | ||
jsxBracketSameLine: true, | ||
trailingComma: 'all', | ||
tabWidth: 4, | ||
arrowParens: 'avoid', | ||
// printWidth: 120, | ||
printWidth: 120, | ||
}; |
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 @@ | ||
{ | ||
"recommendations": [ | ||
"dbaeumer.vscode-eslint" | ||
] | ||
} |
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,7 @@ | ||
{ | ||
"eslint.workingDirectories": [ | ||
{ | ||
"mode": "auto" | ||
} | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Keeping our code style aligned with linting | ||
|
||
We're using linters for a couple of reasons: | ||
- We've experienced a lot of reviews to focus on the stying of code rather than its design and architecture. In particular, this has the potential to be a real turn-off for a newcomer. | ||
- Writing code in a shared style makes way easier to read across files. | ||
- As with any static analysis of code, linting has the potential to find bugs before our users do. | ||
|
||
## Setup your editor to format on save | ||
|
||
To help yourself keep your code passing linters at all times, it's highly recommended to setup your editor to help you. | ||
|
||
### Visual Studio Code | ||
|
||
- Install and enable the ["eslint" extension for VS Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint). | ||
- Make sure you've enabled "format on save" on your workspace. | ||
|
||
Both the eslint plugin and formatting on save can be enabled via the UI or you can <kbd>Cmd</kbd> + <kbd>P</kbd>, type *"> Preferences Open Workspace Settings (JSON)"* and paste in the following in the `settings` object: | ||
|
||
```json | ||
"eslint.format.enable": true, | ||
"editor.formatOnSave": true | ||
``` | ||
|
||
## Running the linters off the CLI | ||
|
||
Linters are run for every pull-request, via [the `pr-linting` workflow](../.github/workflows/pr-linting.yml) on GitHub Actions. | ||
|
||
Every package of this mono-repository should have a `lint` script - to lint, simply change your working directory and run the script: | ||
|
||
``` | ||
npm run lint | ||
``` | ||
|
||
To run linting on every package of the project, use the `lerna:lint` script in the root package: | ||
|
||
``` | ||
npm run lerna:lint | ||
``` | ||
|
||
The linter can automatically fix some issues. To run a fix across every sub-package, you can use the `lerna:lint:fix` script in the root package: | ||
|
||
``` | ||
npm run lerna:lint:fix | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2021 Realm Inc. | ||
// | ||
// Licensed 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 CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
//////////////////////////////////////////////////////////////////////////// | ||
|
||
/* eslint-env node */ | ||
|
||
const currentYear = new Date().getFullYear(); | ||
|
||
const header = [ | ||
"//////////////////////////////////////////////////////////////////////////", | ||
"", | ||
{ pattern: " Copyright \\d{4} Realm Inc.", template: ` Copyright ${currentYear} Realm Inc.` }, | ||
"", | ||
' Licensed 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 CONDITIONS OF ANY KIND, either express or implied.", | ||
" See the License for the specific language governing permissions and", | ||
" limitations under the License.", | ||
"", | ||
"//////////////////////////////////////////////////////////////////////////", | ||
]; | ||
|
||
module.exports = { | ||
plugins: ["header"], | ||
rules: { | ||
"header/header": ["error", "line", header], | ||
}, | ||
}; |
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,6 +1,5 @@ | ||
{ | ||
"extends": "../../../.eslintrc.json", | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
} | ||
} | ||
"env": { | ||
"node": true | ||
} | ||
} |
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,6 +1,6 @@ | ||
{ | ||
"extends": "../../../.eslintrc.json", | ||
"env": { | ||
"mocha": true | ||
"mocha": true, | ||
"node": true | ||
} | ||
} | ||
} |
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,6 +1,6 @@ | ||
{ | ||
"extends": [ | ||
"@react-native-community", | ||
"../../../.eslintrc.json" | ||
"@react-native-community", | ||
"../../../.eslintrc" | ||
] | ||
} |
Oops, something went wrong.