Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Setup megalinter (#365)
Browse files Browse the repository at this point in the history
* Megalinter setup

* test megalinter config

* lint

* test new config

* hot fixes to trigger ci only on pr

* hot fixes to trigger ci only on pr

* check another config

* rename file

* hot fix

* hot fix

* hot fix

* hot fix

* hot fix

* hot fix

* change eslitnrc

* change eslitnrc

* change eslitnrc

* change authorized linter

* change authorized linter

* change authorized linter

* change authorized linter

* change authorized linter

* change authorized linter

* change authorized linter

* changes required for linter

* changes required for linter

* changes required for linter

* changes required for linter

* changes required for linter

* changes required for linter

* Update .github/workflows/mega-linter.yml

Co-authored-by: Guillaume  <[email protected]>

Co-authored-by: Célian Riboulet <[email protected]>
  • Loading branch information
gfroidcourt and celian-rib authored Dec 11, 2022
1 parent 12346cf commit caef74a
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 14 deletions.
9 changes: 5 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// 0 = off
// 1 = warn
// 2 = error
{
"env": {
"es2022": true,
Expand All @@ -20,9 +17,9 @@
},
"plugins": [
"react",
"react-native",
"react-hooks",
"import",
"react-native",
"import-newlines"
],
"rules": {
Expand Down Expand Up @@ -86,6 +83,10 @@
],
"react/no-array-index-key": 0,
"react/jsx-one-expression-per-line": 0,
"react/jsx-indent": [
2,
2
],
"react-native/no-unused-styles": 1,
"key-spacing": [
"error",
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
name: Lint

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches-ignore:
- PRODUCTION
# more infos on possible types here : https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#pull_request

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all)
APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request)

jobs:
megalinter:
permissions: write-all
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
# Git Checkout
- name: Checkout Code
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
fetch-depth: 0

# MegaLinter
- name: MegaLinter
id: ml
# You can override MegaLinter flavor used to have faster performances
# More info at https://oxsecurity.github.io/megalinter/flavors/
uses: oxsecurity/megalinter/flavors/[email protected]
env:
# All available variables are described in documentation
# https://oxsecurity.github.io/megalinter/configuration/
# Apply linter fixes configuration
VALIDATE_ALL_CODEBASE: false # to change
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Upload MegaLinter artifacts create dir
- name: Archive production artifacts create dir
if: ${{ failure() }}
run: mkdir -p megalinter-reports/linters_logs/
# Upload MegaLinter artifacts
- name: Archive production artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: MegaLinter reports
path: megalinter-reports/linters_logs/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ buck-out/
/vendor/bundle/

.env

megalinter-reports/
20 changes: 20 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"threshold": 20,
"reporters": ["html", "markdown"],
"ignore": [
"**/node_modules/**",
"**/.git/**",
"**/.rbenv/**",
"**/.venv/**",
"**/*cache*/**",
"**/.github/**",
"**/.idea/**",
"**/report/**",
"**/*.svg",
"**/*.yml",
"**/*.yaml",
"**/*.md",
"**/android/**",
"**/ios/**"
]
}
41 changes: 41 additions & 0 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Configuration file for MegaLinter
# See all available variables at https://megalinter.io/configuration/ and in linters documentation

APPLY_FIXES: all
ENABLE:
- COPYPASTE
- REPOSITORY

DISABLE_LINTERS:
- REPOSITORY_GITLEAKS

PRINT_ALL_FILES: false
FILTER_REGEX_EXCLUDE: '(\.automation/test|\.automation/generated|\.github/workflows|docs/javascripts|docs/overrides|docs/json-schemas|flavors|clj-kondo|TEMPLATES)'
JSON_JSONLINT_FILTER_REGEX_EXCLUDE: '(\.vscode/)'
YAML_YAMLLINT_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml)'
YAML_PRETTIER_FILTER_REGEX_EXCLUDE: '(templates/\.mega-linter\.yml|mkdocs\.yml)'
YAML_V8R_FILTER_REGEX_EXCLUDE: '(descriptors|templates/\.mega-linter\.yml|\.codecov\.yml)'
BASH_FILTER_REGEX_EXCLUDE: "(lib)"
MARKDOWN_FILTER_REGEX_EXCLUDE: '(license\.md)'
MARKDOWN_MARKDOWN_LINK_CHECK_DISABLE_ERRORS: true
REPOSITORY_TRIVY_DISABLE_ERRORS: true
SPELL_MISSPELL_FILTER_REGEX_EXCLUDE: '(\.automation/generated|docs/descriptors|used-by-stats)'
DOCKERFILE_HADOLINT_ARGUMENTS: "--ignore DL3003 --ignore DL3007 --ignore DL3013 --ignore DL3016 --ignore DL3018 --ignore DL3028 --ignore DL3059 --ignore DL4001 --ignore DL4006 --ignore SC2015 --ignore SC2016 --ignore SC2039 --ignore SC2086 --ignore SC1091 --ignore SC3046"
REPOSITORY_TRIVY_ARGUMENTS:
- "--skip-dirs"
- ".automation/test"
SHOW_ELAPSED_TIME: true
EMAIL_REPORTER: false
FILEIO_REPORTER: true
JSON_REPORTER: true
GITHUB_STATUS_REPORTER: false
PLUGINS:
- https://raw.githubusercontent.com/oxsecurity/megalinter/main/.automation/test/mega-linter-plugin-test/test.megalinter-descriptor.yml
PRE_COMMANDS:
- command: npm install
cwd: "workspace"
- command: npm run lint:fix
cwd: "workspace"
POST_COMMANDS:
- command: echo "This is MegaLinter POST_COMMAND on own MegaLinter ! :)"
cwd: "workspace"
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/map/DropyMapMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const DropyMapMarker = ({ dropy, onPress }) => {
ellipsizeMode='clip'
allowFontScaling={false}
style={{ ...Fonts.bold(8, Colors.lightGrey), fontSize: 7 }}>
DROP
DROP
</Text>
<Text
numberOfLines={1}
Expand All @@ -65,7 +65,7 @@ const DropyMapMarker = ({ dropy, onPress }) => {
ellipsizeMode='clip'
allowFontScaling={false}
style={{ ...Fonts.bold(10, Colors.white), fontSize: 12 }}>
PICK UP
PICK UP
</Text>
</View>
)}
Expand Down
1 change: 0 additions & 1 deletion src/components/other/HomeScreenTabBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ const DropyWheelItem = ({ children, index, childCount, size }) => {
};

return (
// eslint-disable-next-line react-native/no-inline-styles
<View onLayout={handleLayout} key={index} style={{ position: 'absolute', top: coords.y, left: coords.x }}>
{children}
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/components/overlays/DisabledNotificationsPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DisabledNotificationsPopup = () => {
return null;

return (
<TouchableOpacity onPress={Linking.openSettings} style={{ ...styles.container }}>
<TouchableOpacity onPress={() => Linking.openSettings()} style={{ ...styles.container }}>
<Text style={{ ...Fonts.regular(12, Colors.white) }}>Notifications are disabled</Text>
<TouchableOpacity onPress={() => setVisible(false)} hitSlop={{ bottom: 10, left: 20, right: 10, top: 10 }}>
<AntDesign name='close' size={17} color={Colors.white} />
Expand Down
9 changes: 6 additions & 3 deletions src/screens/CreateDropyTextScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,18 @@ const CreateDropyTextScreen = ({ navigation, route }) => {
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
style={styles.inputContainer}
><TouchableWithoutFeedback onPress={Keyboard.dismiss}>
<TextInput placeholder='What do you want to tell anybody ? '
>
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<TextInput
placeholder='What do you want to tell anybody ? '
multiline={true}
placeholderTextColor={Colors.lightGrey}
style={styles.textInput}
blurOnSubmit
autoFocus
onChangeText={(text) => setText(text)}
value={text}/>
value={text}
/>
</TouchableWithoutFeedback>
<GlassButton
style={styles.largeButton}
Expand Down
2 changes: 1 addition & 1 deletion src/screens/HomeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const HomeScreen = ({ navigation, route }) => {
<View style={styles.backgroundGeolocIconInnerContainer}>
<FontAwesome5 name='satellite-dish' size={BACKGROUND_GEOLOC_ICON_OPENED_SIZE - 20} color={backgroundGeolocationEnabled ? Colors.mainBlue : Colors.grey} />
<Text allowFontScaling={false} style={styles.backgroundGeolocationText}>
Background location {backgroundGeolocationEnabled ? 'enabled' : 'disabled'}
Background location {backgroundGeolocationEnabled ? 'enabled' : 'disabled'}
</Text>
</View>
</Animated.View>
Expand Down
2 changes: 1 addition & 1 deletion src/states/DropiesAroundContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const DropiesAroundContextProvider = ({ children }) => {
const restrictedRange = updatedDropies.some((dropy) => dropy.isInEmitRestrictedRange);
setCanEmitDropy(!restrictedRange);

const requireStateUpdate = updatedDropies.some((dropy) => dropy.reachable !== dropy.reachable);
const requireStateUpdate = updatedDropies.some((dropy, index) => dropy.reachable !== dropiesAround[index].reachable);
if (requireStateUpdate)
setDropiesAround(updatedDropies);
};
Expand Down

0 comments on commit caef74a

Please sign in to comment.