mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-19 17:58:48 +00:00
Remove backbone as a dependency
Co-authored-by: Yash <yash@signal.org> Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com> Co-authored-by: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
import { run } from 'endanger';
|
||||
|
||||
import migrateBackboneToRedux from './rules/migrateBackboneToRedux';
|
||||
import packageJsonVersionsShouldBePinned from './rules/packageJsonVersionsShouldBePinned';
|
||||
import pnpmLockDepsShouldHaveIntegrity from './rules/pnpmLockDepsShouldHaveIntegrity';
|
||||
|
||||
@@ -19,7 +18,6 @@ function isGitDeletedError(error: unknown) {
|
||||
async function main() {
|
||||
try {
|
||||
await run(
|
||||
migrateBackboneToRedux(),
|
||||
packageJsonVersionsShouldBePinned(),
|
||||
pnpmLockDepsShouldHaveIntegrity()
|
||||
);
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
// Copyright 2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { Line, Rule } from 'endanger';
|
||||
|
||||
export default function migrateBackboneToRedux() {
|
||||
return new Rule({
|
||||
match: {
|
||||
files: ['**/*.{js,jsx,ts,tsx}'],
|
||||
},
|
||||
messages: {
|
||||
foundNewBackboneFile: `
|
||||
**Prefer Redux**
|
||||
Don't create new Backbone files, use Redux
|
||||
`,
|
||||
foundBackboneFileWithManyChanges: `
|
||||
**Prefer Redux**
|
||||
Migrate Backbone files to Redux when making major changes
|
||||
`,
|
||||
},
|
||||
async run({ files, context }) {
|
||||
for (let file of files.modifiedOrCreated) {
|
||||
let lines = await file.lines();
|
||||
let matchedLine: Line | null = null;
|
||||
|
||||
for (let line of lines) {
|
||||
// Check for the most stable part of the backbone `import`
|
||||
if (
|
||||
(await line.contains("from 'backbone'")) ||
|
||||
(await line.contains('window.Backbone'))
|
||||
) {
|
||||
matchedLine = line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!matchedLine) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.created) {
|
||||
context.warn('foundNewBackboneFile', { file, line: matchedLine });
|
||||
} else if (file.modifiedOnly) {
|
||||
if (await file.diff().changedBy({ added: 0.1 })) {
|
||||
context.warn('foundBackboneFileWithManyChanges', {
|
||||
file,
|
||||
line: matchedLine,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -20,7 +20,7 @@ function has<T extends object, const K extends T[any]>(
|
||||
return Object.hasOwn(value, key);
|
||||
}
|
||||
|
||||
export default function migrateBackboneToRedux() {
|
||||
export default function pnpmLockDepsShouldHaveIntegrity() {
|
||||
return new Rule({
|
||||
match: {
|
||||
files: ['pnpm-lock.yaml'],
|
||||
|
||||
Reference in New Issue
Block a user