mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-21 09:38:01 +02:00
Improve eslint rules and run them from CI
This commit is contained in:
parent
2c522637ef
commit
637a4dc1f9
32
.eslintrc.js
32
.eslintrc.js
@ -33,14 +33,22 @@ module.exports = {
|
|||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
},
|
},
|
||||||
'rules': {
|
'rules': {
|
||||||
|
// -------------------------------
|
||||||
|
// Code correctness
|
||||||
|
// -------------------------------
|
||||||
"react/jsx-uses-react": "error",
|
"react/jsx-uses-react": "error",
|
||||||
"react/jsx-uses-vars": "error",
|
"react/jsx-uses-vars": "error",
|
||||||
// Ignore all unused function arguments, because in some
|
"no-unused-vars": "error",
|
||||||
// case they are kept to indicate the function signature.
|
|
||||||
//"no-unused-vars": ["error", { "argsIgnorePattern": ".*" }],
|
|
||||||
"@typescript-eslint/no-unused-vars": ["error"],
|
|
||||||
"no-constant-condition": 0,
|
"no-constant-condition": 0,
|
||||||
"no-prototype-builtins": 0,
|
"no-prototype-builtins": 0,
|
||||||
|
// This error is always a false positive so far since it detects
|
||||||
|
// possible race conditions in contexts where we know it cannot happen.
|
||||||
|
"require-atomic-updates": 0,
|
||||||
|
"no-lonely-if": "error",
|
||||||
|
|
||||||
|
// -------------------------------
|
||||||
|
// Formatting
|
||||||
|
// -------------------------------
|
||||||
"space-in-parens": ["error", "never"],
|
"space-in-parens": ["error", "never"],
|
||||||
"semi": ["error", "always"],
|
"semi": ["error", "always"],
|
||||||
"eol-last": ["error", "always"],
|
"eol-last": ["error", "always"],
|
||||||
@ -49,11 +57,19 @@ module.exports = {
|
|||||||
"comma-dangle": ["error", "always-multiline"],
|
"comma-dangle": ["error", "always-multiline"],
|
||||||
"no-trailing-spaces": "error",
|
"no-trailing-spaces": "error",
|
||||||
"linebreak-style": ["error", "unix"],
|
"linebreak-style": ["error", "unix"],
|
||||||
// This error is always a false positive so far since it detects
|
|
||||||
// possible race conditions in contexts where we know it cannot happen.
|
|
||||||
"require-atomic-updates": 0,
|
|
||||||
"prefer-template": ["error"],
|
"prefer-template": ["error"],
|
||||||
"template-curly-spacing": ["error", "never"]
|
"template-curly-spacing": ["error", "never"],
|
||||||
|
"key-spacing": ["error", {
|
||||||
|
"beforeColon": false,
|
||||||
|
"afterColon": true,
|
||||||
|
"mode": "strict"
|
||||||
|
}],
|
||||||
|
"block-spacing": ["error"],
|
||||||
|
"brace-style": ["error", "1tbs"],
|
||||||
|
"no-spaced-func": ["error"],
|
||||||
|
"func-call-spacing": ["error"],
|
||||||
|
"space-before-function-paren": ["error", "never"],
|
||||||
|
"object-property-newline": ["error"]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"react",
|
"react",
|
||||||
|
17
.travis.yml
17
.travis.yml
@ -55,17 +55,30 @@ before_install:
|
|||||||
script:
|
script:
|
||||||
- |
|
- |
|
||||||
# Install tools
|
# Install tools
|
||||||
|
npm install
|
||||||
cd Tools
|
cd Tools
|
||||||
npm install
|
npm install
|
||||||
|
cd ..
|
||||||
|
|
||||||
# Run test units
|
# Run test units
|
||||||
cd ../CliClient
|
cd CliClient
|
||||||
npm install
|
npm install
|
||||||
./run_test.sh
|
./run_test.sh
|
||||||
testResult=$?
|
testResult=$?
|
||||||
if [ $testResult -ne 0 ]; then
|
if [ $testResult -ne 0 ]; then
|
||||||
exit $testResult
|
exit $testResult
|
||||||
fi
|
fi
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
# Run linter for pull requests only - this is so that
|
||||||
|
# bypassing eslint is allowed for urgent fixes.
|
||||||
|
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
|
||||||
|
npm run linter-ci ./
|
||||||
|
testResult=$?
|
||||||
|
if [ $testResult -ne 0 ]; then
|
||||||
|
exit $testResult
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Find out if we should run the build or not. Electron-builder gets stuck when
|
# Find out if we should run the build or not. Electron-builder gets stuck when
|
||||||
# builing PRs so we disable it in this case. The Linux build should provide
|
# builing PRs so we disable it in this case. The Linux build should provide
|
||||||
@ -78,6 +91,6 @@ script:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare the Electron app and build it
|
# Prepare the Electron app and build it
|
||||||
cd ../ElectronClient/app
|
cd ElectronClient/app
|
||||||
rsync -aP --delete ../../ReactNativeClient/lib/ lib/
|
rsync -aP --delete ../../ReactNativeClient/lib/ lib/
|
||||||
npm install && USE_HARD_LINKS=false yarn dist
|
npm install && USE_HARD_LINKS=false yarn dist
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Joplin root package for linting",
|
"description": "Joplin root package for linting",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"linter": "./node_modules/.bin/eslint --fix --ext .js --ext .jsx"
|
"linter": "./node_modules/.bin/eslint --fix --ext .js --ext .jsx",
|
||||||
|
"linter-ci": "./node_modules/.bin/eslint --ext .js --ext .jsx"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
|
Loading…
Reference in New Issue
Block a user