-
Notifications
You must be signed in to change notification settings - Fork 583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add betterer #8045
feat: add betterer #8045
Changes from 12 commits
e1a6a30
12b1c73
f4af17b
a65902c
21cec12
6c0f3dd
fae1d6e
7218208
0b7868e
9087a19
9108889
e0f9750
19b0715
73cae93
bc30422
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { regexp } from "@betterer/regexp" | ||
import { BettererFileTest } from "@betterer/betterer" | ||
|
||
const typescriptFiles = ["./src/**/*.ts", "./src/**/*.tsx"] | ||
const typescriptTestFiles = ["./src/**/*.tests.ts", "./src/**/*.tests.tsx"] | ||
const imageExtensionsToAvoid = ["png", "jpg", "jpeg"] | ||
|
||
export default { | ||
"Stop using useAnimatedValue, use useSharedValue instead!": () => | ||
regexp(/useAnimatedValue\(/).include(typescriptFiles), | ||
|
||
"Stop using moment, use luxon instead!": () => | ||
regexp(/from "(moment|moment-timezone)"/).include(typescriptFiles), | ||
|
||
"Finish our strictnes migration!": () => | ||
regexp(/Unsafe legacy code 🚨 Please delete this/).include(typescriptFiles), | ||
|
||
"Avoid non-webp images!": () => | ||
countNonWebpImages().include([`./images/**/*.{${imageExtensionsToAvoid.join(",")}}`]), | ||
pvinis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
"Avoid using test-renderer!": () => | ||
regexp(/renderWithWrappersLEGACY.* from ".*renderWithWrappers"/).include(typescriptTestFiles), | ||
|
||
"Remove all relay unmocks!": () => regexp(/unmock\("react-relay"\)/).include(typescriptTestFiles), | ||
|
||
"Fix all STRICTNESS_MIGRATION!": () => regexp(/STRICTNESS_MIGRATION/).include(typescriptFiles), | ||
|
||
"Avoid having skipped tests!": () => | ||
regexp(/(fdescribe\(|describe.only\(|fit\(|xit\(|it.only\(|it.skip\()/).include( | ||
typescriptTestFiles | ||
), | ||
|
||
"Avoid using class components!": () => | ||
regexp(/extends (React\.)?Component/).include(typescriptFiles), | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❇️ |
||
|
||
const countNonWebpImages = () => | ||
new BettererFileTest(async (filePaths, fileTestResult) => { | ||
filePaths.forEach((filePath) => { | ||
// the file contents don't matter | ||
const file = fileTestResult.addFile(filePath, "") | ||
file.addIssue( | ||
0, | ||
0, | ||
"don't use non-webp images. you can use the script to convert other formats to webp." | ||
) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
|
||
|
||
yarn lint-staged | ||
yarn secrets:check:staged | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. moved to lint-staged |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
|
||
|
||
yarn type-check | ||
yarn betterer:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one final check |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extracted this into a config file |
||
"*.@(ts|tsx)": ["yarn lint", "yarn prettier-write"], | ||
"*.@(json|md)": ["yarn prettier-write"], | ||
"*": ["yarn secrets:check:staged", "yarn betterer:precommit"], | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extracted this into a config file (i tried .mjs with |
||
printWidth: 100, | ||
semi: false, | ||
singleQuote: false, | ||
trailingComma: "es5", | ||
bracketSpacing: true, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": ["Orta.vscode-ios-common-files", "Orta.vscode-danger", "artsy.artsy-studio-extension-pack", "meta.relay"], | ||
"recommendations": [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. random linting |
||
"Orta.vscode-ios-common-files", | ||
"artsy.artsy-studio-extension-pack", | ||
"meta.relay" | ||
], | ||
"unwantedRecommendations": ["prisma.vscode-graphql"] | ||
} |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look at all these nice rules :)