This repository was archived by the owner on Aug 30, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 101
Nettoyage du code #689
Closed
Gabriel29306
wants to merge
100
commits into
PapillonApp:main
from
Gabriel29306:clean-the-code-as-fuck-is-possible
Closed
Nettoyage du code #689
Changes from all commits
Commits
Show all changes
100 commits
Select commit
Hold shift + click to select a range
990e129
feat(action): test build actions
Gabriel29306 5194655
fix(action): build version
Gabriel29306 688de03
fix(action): build using expo prebuild
Gabriel29306 19a10cd
fix(action): indent
Gabriel29306 4b288c5
fix(action): indent
Gabriel29306 41bf273
fix(action): use java 17
Gabriel29306 1a1bae8
fix(action): Increment Version Based on Release
Gabriel29306 567d42e
fix(action): resolve publish errors
Gabriel29306 451dca0
fix(action): tests
Gabriel29306 e1f7614
fix(action): test
Gabriel29306 b458b96
fix(action): test
Gabriel29306 b1f3d27
fix(actions): test
Gabriel29306 fa2e4f8
fix(action): Is ot going to work this time ?
Gabriel29306 6008824
fix(action): Why isn't working !
Gabriel29306 2b24232
fix(action): tag name
Gabriel29306 8ef1594
chore(action): remove debug
Gabriel29306 6a6766b
fix(action)
Gabriel29306 824ab0a
fix(action)
Gabriel29306 8ed4ad7
debug
Gabriel29306 ada785b
debug
Gabriel29306 e3e6f0d
fix(action): include pre versions in get latest version
Gabriel29306 b0f827a
Merge branch 'PapillonApp:main' into main
Gabriel29306 8999f7e
Merge branch 'PapillonApp:main' into main
Gabriel29306 d85268e
fix(build): let gradle choose the good sdk
Gabriel29306 551f089
fix: Rename service_alise.png to service_alise.jpg
Gabriel29306 1d51262
fix(action): Rename service_alise.png to service_alise.jpg
Gabriel29306 806d4cf
fix(action): update service_alise.png into service_alise.jpg in all f…
Gabriel29306 7d796c2
chore(action): remove unnecessary step
Gabriel29306 37bc830
Merge branch 'PapillonApp:main' into main
Gabriel29306 835c2c0
feat(action/build): add emojis to steps
Gabriel29306 7b428b5
Merge branch 'PapillonApp:main' into main
Gabriel29306 9a5b080
Merge branch 'PapillonApp:main' into main
Gabriel29306 792dc97
feat(action/build): Change weekly build time for 00h00 UTC
Gabriel29306 fe78a9a
fix(action): update pawnote to permit Papillon to work in new Pronote…
Gabriel29306 c4c594a
Merge branch 'PapillonApp:main' into main
Gabriel29306 704c81d
chore(action): remove unused step
Gabriel29306 4340bad
Merge branch 'PapillonApp:main' into main
Gabriel29306 544f1e2
lint: don't use `var`
Gabriel29306 84f98b4
lint: inaccesible code
Gabriel29306 31bd5de
lint: simplify conditions
Gabriel29306 888f024
lint: remove unecessary keywords `void`, `return`, `await`
Gabriel29306 4de5164
perf: add missing `break`
Gabriel29306 f5fc04d
lint: unecessary instruction
Gabriel29306 ac5569c
lint: simplify ratio (`1/1`=>`1`)
Gabriel29306 5ba5eb0
lint: `useEffect` need to be called in every render.
Gabriel29306 52f4498
feat(lint): unused vars
Gabriel29306 f6166de
feat(tsconfig): add `jsx` option
Gabriel29306 7a50028
fix: lint
Gabriel29306 4914397
fix(lint): ignore func args for unused var
Gabriel29306 e4e777c
lint: remove unused variables
Gabriel29306 b0e65a4
feat(lint): discouraging the use of var and encouraging the use of co…
Gabriel29306 b6cca91
lint: duplicated imports
Gabriel29306 c5f0d33
lint: no-unneeded-ternary
Gabriel29306 0da5aec
lint: remove extra semicolons
Gabriel29306 c4e0832
lint: no-irregular-whitespace
Gabriel29306 5a4bb41
lint: no-mixed-spaces-and-tabs
Gabriel29306 8ca9ff2
lint: no-empty
Gabriel29306 be68e53
lint: no-useless-escape
Gabriel29306 047ed6a
Merge branch 'PapillonApp:main' into main
Gabriel29306 93a6f2f
feat(lint): add custom rules
Gabriel29306 8c3f1ee
lint: simplify ternary
Gabriel29306 4b93ba4
Merge remote-tracking branch 'origin' into clean-the-code-as-fuck-is-…
Gabriel29306 11e139a
lint
Gabriel29306 e33ea6f
Merge branch 'PapillonApp:main' into main
Gabriel29306 337ff94
feat(build): add patchs
Gabriel29306 3ea338c
Update build.yml
Gabriel29306 0bb93c9
Update build.yml
Gabriel29306 61d9a72
Merge remote-tracking branch 'origin/main' into clean-the-code-as-fuc…
d5735fb
chore: remove unusable file
Gabriel29306 6d3bb38
Merge remote-tracking branch 'origin/main' into clean-the-code-as-fuc…
Gabriel29306 ca238c3
chore(lint): semicolon and eol-last
Gabriel29306 8629588
chore(lint): imports
Gabriel29306 7b50c97
chore(lint): readability
Gabriel29306 f116ac3
chore(lint): typing
Gabriel29306 6c28603
chore(lint): unused
Gabriel29306 fb58299
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 1a01791
feat(logs): use custom logger instead of console builtin and enhance …
Gabriel29306 b29e3e2
fix: package-lock.json
Gabriel29306 a7eb333
fix: package-lock.json
Gabriel29306 7eb513b
fix(lint): remove unused comma
Gabriel29306 c186e80
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 7cd3f17
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 01c933d
chore(lint)
Gabriel29306 2f3dc20
fix(vscode): oups
Gabriel29306 8742457
chore(lint)
Gabriel29306 9a14363
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 55d3f9b
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 9791c20
feat(lint): arrow-spacing
Gabriel29306 1b12f21
chore: use `TouchableOpacity` from react-native instead of react-nati…
Gabriel29306 65600e1
chore: remove unused file
Gabriel29306 8b4b698
feat(lint): remove unused func args
Gabriel29306 0e621c9
fi(lint): unued assertion
Gabriel29306 ada94dd
feat(restaurant): use hook instead of static to use actualised version
Gabriel29306 ff1ff70
feat(esthetic): split the two useState var into pair
Gabriel29306 a8ff2b2
feat(lint): simplify ternary
Gabriel29306 6eca183
feat(lint): esthetic
Gabriel29306 dbcf632
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 88792cf
Merge remote-tracking branch 'origin/main' into clean-the-code-as-fuc…
Gabriel29306 68cb4a0
lint
Gabriel29306 2cf145b
Merge branch 'main' into clean-the-code-as-fuck-is-possible
Gabriel29306 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -12,4 +12,4 @@ | |
"lint" | ||
], | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -8,4 +8,4 @@ module.exports = function (api) { | |
"react-native-reanimated/plugin" | ||
], | ||
}; | ||
}; | ||
}; |
This file contains hidden or 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 hidden or 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,78 @@ | ||
module.exports = { | ||
meta: { | ||
type: "suggestion", | ||
docs: { | ||
description: "Detect and transform nested ternary operators into nullish coalescing chains", | ||
category: "Best Practices", | ||
recommended: false | ||
}, | ||
schema: [], | ||
messages: { | ||
redundantNestedTernary: "The nested ternary can be simplified using nullish coalescing operators" | ||
}, | ||
fixable: "code", | ||
}, | ||
create (context) { | ||
function processConditionalExpression (node) { | ||
const sourceCode = context.getSourceCode(); | ||
|
||
// Fonction récursive pour construire la chaîne de nullish coalescing | ||
function buildNullishChain (node) { | ||
if (node.type !== "ConditionalExpression") { | ||
return sourceCode.getText(node); | ||
} | ||
|
||
const test = sourceCode.getText(node.test); | ||
|
||
// Si c'est un ternaire imbriqué dans l'alternate | ||
if (node.alternate.type === "ConditionalExpression") { | ||
// Récupérer l'expression complète du consequent | ||
const nextValueNode = node.alternate.consequent; | ||
|
||
// Si c'est un accès à une propriété imbriquée, ajouter l'optional chaining | ||
if (nextValueNode.type === "MemberExpression") { | ||
const object = sourceCode.getText(nextValueNode.object); | ||
const property = sourceCode.getText(nextValueNode.property); | ||
return `${test} ?? ${object}?.${property} ?? ${sourceCode.getText(node.alternate.alternate)}`; | ||
} | ||
|
||
const nextValue = sourceCode.getText(nextValueNode); | ||
return `${test} ?? ${nextValue} ?? ${sourceCode.getText(node.alternate.alternate)}`; | ||
} | ||
|
||
return `${test} ?? ${sourceCode.getText(node.alternate)}`; | ||
} | ||
|
||
// Vérifie si c'est un cas valide à transformer | ||
function isValidTransform (node) { | ||
if (!node || node.type !== "ConditionalExpression") return false; | ||
|
||
const test = sourceCode.getText(node.test); | ||
const consequent = sourceCode.getText(node.consequent); | ||
|
||
// Soit test et consequent sont identiques | ||
if (test === consequent) return true; | ||
|
||
// Soit c'est dans un alternate d'un ternaire valide | ||
return !!(node.parent?.type === "ConditionalExpression" | ||
&& node.parent.alternate === node | ||
&& isValidTransform(node.parent)); | ||
} | ||
|
||
// Vérifie si c'est un cas de ternaire imbriqué à transformer | ||
if (isValidTransform(node)) { | ||
context.report({ | ||
node, | ||
messageId: "redundantNestedTernary", | ||
fix (fixer) { | ||
return fixer.replaceText(node, buildNullishChain(node)); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
return { | ||
ConditionalExpression: processConditionalExpression | ||
}; | ||
} | ||
}; |
This file contains hidden or 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,10 @@ | ||
const redundant_logical = require("./redundant-logical.js"); | ||
const no_redundant_ternary = require("./no-redundant-ternary.js"); | ||
|
||
const plugin = { | ||
rules: { | ||
"redundant-logical": redundant_logical, | ||
"no-redundant-ternary": no_redundant_ternary | ||
} | ||
}; | ||
module.exports = plugin; |
This file contains hidden or 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,63 @@ | ||
const ts = require("typescript"); | ||
|
||
module.exports = { | ||
meta: { | ||
type: "problem", | ||
docs: { | ||
description: "Detect redundant `x || x.y` or `x && x` patterns", | ||
category: "Best Practices", | ||
recommended: false | ||
}, | ||
schema: [], | ||
messages: { | ||
redundantLogical: "The logical expression `{{ expression }}` is redundant. Consider simplifying it." | ||
} | ||
}, | ||
create (context) { | ||
const parserServices = context.parserServices; | ||
if (!parserServices?.program) { | ||
return {}; // Ignorer si TypeScript n'est pas activé | ||
} | ||
const typeChecker = parserServices.program.getTypeChecker(); | ||
|
||
return { | ||
LogicalExpression (node) { | ||
if (node.operator === "&&" || node.operator === "||") { | ||
const left = context.getSourceCode().getText(node.left); | ||
const right = context.getSourceCode().getText(node.right); | ||
|
||
if (right.startsWith(left)) { | ||
const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node.left); | ||
const type = typeChecker.getTypeAtLocation(tsNode); | ||
const isNullable = (type.getFlags() & ts.TypeFlags.Null) !== 0; | ||
|
||
if ((node.operator === "&&" && isNullable) || | ||
(node.operator === "||" && !isNullable)) { | ||
return; | ||
} | ||
|
||
// Extraire la partie après le point (ex: pour "x.y", on récupère "y") | ||
const suffix = right.slice(left.length); | ||
|
||
context.report({ | ||
node, | ||
messageId: "redundantLogical", | ||
data: { | ||
expression: `${left} ${node.operator} ${right}` | ||
}, | ||
fix (fixer) { | ||
if (node.operator === "&&") { | ||
// Pour &&, utiliser l'opérateur optionnel | ||
return fixer.replaceText(node, `${left}?${suffix}`); | ||
} else { | ||
// Pour ||, utiliser l'accès direct | ||
return fixer.replaceText(node, `${right}`); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
}; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.