Skip to content

Commit

Permalink
feat: add betterer (#8045)
Browse files Browse the repository at this point in the history
* this is great!

* try ci

* class components

* unmock

* works

* hm

* this

* move stuff around

* Delete betterer-check.yml

* strictness

* cache and sort

* ci

* not now

* fixed

* Update .circleci/config.yml
  • Loading branch information
pvinis authored Jan 25, 2023
1 parent 326e7ee commit bbf03aa
Show file tree
Hide file tree
Showing 20 changed files with 3,075 additions and 955 deletions.
2,652 changes: 2,652 additions & 0 deletions .betterer.results

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions .betterer.ts
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(",")}}`]),

"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),
}

// 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."
// )
// })
// })
13 changes: 3 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,9 @@ jobs:
- checkout
- generate-checksums
- install-node-modules
- run-relay-compiler
- run:
name: Danger
command: yarn danger ci --verbose
- run:
name: Prevent Strictness Regressions
command: node scripts/strictness-migration.js check-pr
name: Betterer
command: yarn ci:betterer-check

check-flags:
environment:
Expand Down Expand Up @@ -424,10 +420,6 @@ jobs:
path: xcode_test_raw.log
prefix: tests

- run:
name: Danger
command: bundle exec danger --danger_id=circle --dangerfile=Dangerfile.circle.rb --verbose

- await-previous-builds:
branch: beta-ios
- run:
Expand Down Expand Up @@ -574,6 +566,7 @@ workflows:
- app_store_submission
- play_store_submission
- update-changelog

- build-test-js:
filters:
branches:
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ package-lock.json
yarn-error.log


# Danger artifacts
eslint-errors.json

# typescript
Expand All @@ -83,9 +82,6 @@ native-code-checksum.hash

.manifests

# user-managed "state" files
.i-am-helping-out-with-the-strictness-migration

# auto-managed "state" files
.i-had-a-netrc-file

Expand Down
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@


yarn lint-staged
yarn secrets:check:staged
1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@


yarn type-check
yarn betterer:all
5 changes: 5 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
"*.@(ts|tsx)": ["yarn lint", "yarn prettier-write"],
"*.@(json|md)": ["yarn prettier-write"],
"*": ["yarn secrets:check:staged", "yarn betterer:precommit"],
}
7 changes: 7 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
printWidth: 100,
semi: false,
singleQuote: false,
trailingComma: "es5",
bracketSpacing: true,
}
6 changes: 5 additions & 1 deletion .vscode/extensions.json
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": [
"Orta.vscode-ios-common-files",
"artsy.artsy-studio-extension-pack",
"meta.relay"
],
"unwantedRecommendations": ["prisma.vscode-graphql"]
}
32 changes: 0 additions & 32 deletions Dangerfile.circle.rb

This file was deleted.

1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ group :development do
end

group :test do
gem 'danger' # Stop saying 'you forgot to...', used only on Circle CI
gem 'xcode-install' # To ensure we have the right SDK installed for running tests
gem 'xcpretty' # Makes CI readable
end
Expand Down
40 changes: 1 addition & 39 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ GEM
nio4r (>= 1.1)
timers (>= 4.1.1)
claide (1.1.0)
claide-plugins (0.9.2)
cork
nap
open4 (~> 1.3)
cocoapods (1.11.3)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
Expand Down Expand Up @@ -88,21 +84,6 @@ GEM
commander (4.6.0)
highline (~> 2.0.0)
concurrent-ruby (1.1.10)
cork (0.3.0)
colored2 (~> 3.1)
danger (8.6.1)
claide (~> 1.0)
claide-plugins (>= 0.9.2)
colored2 (~> 3.1)
cork (~> 0.1)
faraday (>= 0.9.0, < 2.0)
faraday-http-cache (~> 2.0)
git (~> 1.7)
kramdown (~> 2.3)
kramdown-parser-gfm (~> 1.0)
no_proxy_fix
octokit (~> 4.7)
terminal-table (>= 1, < 4)
declarative (0.0.20)
digest-crc (0.6.4)
rake (>= 12.0.0, < 14.0.0)
Expand Down Expand Up @@ -134,8 +115,6 @@ GEM
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-http-cache (2.4.1)
faraday (>= 0.8)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
Expand Down Expand Up @@ -193,9 +172,6 @@ GEM
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
git (1.12.0)
addressable (~> 2.8)
rchardet (~> 1.8)
google-apis-androidpublisher_v3 (0.29.0)
google-apis-core (>= 0.9.0, < 2.a)
google-apis-core (0.9.0)
Expand Down Expand Up @@ -244,10 +220,6 @@ GEM
jmespath (1.6.1)
json (2.6.2)
jwt (2.5.0)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
lowdown (1.0.0)
celluloid-io (>= 0.17.3)
http-2 (>= 0.8)
Expand All @@ -263,19 +235,13 @@ GEM
naturally (2.2.1)
netrc (0.11.0)
nio4r (2.5.8)
no_proxy_fix (0.1.2)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
open4 (1.3.4)
optparse (0.1.1)
os (1.1.4)
plist (3.6.0)
psych (4.0.4)
stringio
public_suffix (4.0.7)
rake (13.0.6)
rchardet (1.8.0)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
Expand All @@ -286,9 +252,6 @@ GEM
ruby-macho (2.5.1)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
security (0.1.3)
sentry-ruby (5.4.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand Down Expand Up @@ -343,7 +306,6 @@ PLATFORMS
DEPENDENCIES
cocoapods (= 1.11.3)
cocoapods-check
danger
dotenv
down
fastlane
Expand All @@ -357,4 +319,4 @@ DEPENDENCIES
xcpretty

BUNDLED WITH
2.3.22
2.4.3
26 changes: 0 additions & 26 deletions dangerRules/useWebPs.tests.ts

This file was deleted.

Loading

0 comments on commit bbf03aa

Please sign in to comment.