Skip to content

Commit

Permalink
build: update prettier and eslint-plugin-prettier (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored Dec 12, 2024
1 parent eb24ed9 commit 537aefb
Show file tree
Hide file tree
Showing 37 changed files with 154 additions and 135 deletions.
2 changes: 1 addition & 1 deletion blog/electron-25-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protocol.registerBufferProtocol('some-protocol', () => {
protocol.handle('some-protocol', () => {
return new Response(
Buffer.from('<h5>Response</h5>'), // Could also be a string or ReadableStream.
{ headers: { 'content-type': 'text/html' } }
{ headers: { 'content-type': 'text/html' } },
);
});
```
Expand Down
6 changes: 3 additions & 3 deletions blog/electron-33-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protocol.registerFileProtocol('other', () => {
const mainWindow = new BrowserWindow();
mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://C:\\myapp' }
{ baseURLForDataURL: 'other://C:\\myapp' },
);
mainWindow.loadURL('other://C:\\myapp\\index.html');

Expand All @@ -78,13 +78,13 @@ protocol.handle(other, (req) => {
const srcPath = 'C:\\myapp\\';
const reqURL = new URL(req.url);
return net.fetch(
nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString()
nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString(),
);
});

mainWindow.loadURL(
'data:text/html,<script src="loaded-from-dataurl.js"></script>',
{ baseURLForDataURL: 'other://' }
{ baseURLForDataURL: 'other://' },
);
mainWindow.loadURL('other://index.html');
```
Expand Down
6 changes: 3 additions & 3 deletions blog/electron-4-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ browserWin.webContents.on(
'remote-require',
function (event, requestedModuleName) {
// ...
}
},
);
```

Expand All @@ -66,15 +66,15 @@ app.on(
'remote-get-global',
function (event, webContents, requrestedGlobalName) {
// ...
}
},
);

// Control `remote.getGlobal` from a specific WebContents instance:
browserWin.webContents.on(
'remote-get-global',
function (event, requestedGlobalName) {
// ...
}
},
);
```

Expand Down
4 changes: 2 additions & 2 deletions blog/web-preferences-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const enforceInheritance = (topWebContents) => {
}
Object.assign(
options.webPreferences,
topWebContents.getLastWebPreferences()
topWebContents.getLastWebPreferences(),
);
if (options.webContents) {
handle(options.webContents);
}
}
},
);
};
handle(topWebContents);
Expand Down
2 changes: 1 addition & 1 deletion blog/webview-fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ app.on('web-contents-created', (event, win) => {
options.webPreferences.nodeIntegrationInWorker = false;
options.webPreferences.webviewTag = false;
delete options.webPreferences.preload;
}
},
);
});

Expand Down
2 changes: 1 addition & 1 deletion docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let docsSHA = undefined;
try {
docsSHA = fs.readFileSync(
path.resolve(__dirname, './docs/latest/.sha'),
'utf-8'
'utf-8',
);
} catch {
logger.warn('No .sha file found in docs/latest directory');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"dotenv": "^16.0.3",
"eslint": "^8.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.28.0",
"execa": "^5.0.0",
"globby": "^11.0.3",
Expand All @@ -92,7 +92,7 @@
"mdast-util-mdx": "^3.0.0",
"mdast-util-to-hast": "^13.2.0",
"mdast-util-to-string": "^4.0.0",
"prettier": "^2.8.0",
"prettier": "^3.4.2",
"remark": "^15.0.0",
"remark-gfm": "^4.0.0",
"tar-stream": "^2.2.0",
Expand Down
6 changes: 3 additions & 3 deletions scripts/pre-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const start = async (source: string): Promise<void> => {
const stableBranch = version.replace(/\.\d+\.\d+/, '-x-y');
logger.info(
`Fetching ${logger.green(
`electron`
`electron`,
)} information from npm: \n\t Latest version: ${logger.green(
version
)} \n\t Stable branch: ${logger.green(stableBranch)}`
version,
)} \n\t Stable branch: ${logger.green(stableBranch)}`,
);

const target = source || stableBranch;
Expand Down
4 changes: 2 additions & 2 deletions scripts/prepare-i18n-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const start = async () => {
'i18n',
locale,
'docusaurus-plugin-content-docs',
'current'
'current',
);
const staticResources = ['fiddles', 'images'];

Expand All @@ -31,7 +31,7 @@ const start = async () => {
await fs.cp(
path.join(DOCS_FOLDER, staticResource),
path.join(localeDocs, 'latest', staticResource),
{ recursive: true }
{ recursive: true },
);
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/tasks/copy-new-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const copyNewContent = async (destination: string) => {
for (const [source, target] of newContent) {
await fs.copyFile(
path.join(__dirname, source),
path.join(destination, target)
path.join(destination, target),
);
}
};
8 changes: 4 additions & 4 deletions scripts/tasks/create-sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const capitalize = (title: string) => {
const findCategoryForDocument = (
categoryName: string,
sidebars: Sidebars,
defaultTopLevel: string
defaultTopLevel: string,
) => {
const topLevelIds = Object.keys(sidebars);

Expand Down Expand Up @@ -160,7 +160,7 @@ export const createSidebar = async (root: string, destination: string) => {
const category = findCategoryForDocument(
categoryId,
sidebars,
defaultTopLevel
defaultTopLevel,
);

category.items.push(document.replace('.md', ''));
Expand All @@ -172,11 +172,11 @@ export const createSidebar = async (root: string, destination: string) => {

// run it through our linter
const prettierConfig = await prettier.resolveConfig(
path.resolve(__dirname, '..', '..', '.prettierrc')
path.resolve(__dirname, '..', '..', '.prettierrc'),
);
const formattedSidebarString = await prettier.format(
sidebarString,
prettierConfig
prettierConfig,
);

fs.writeFileSync(destination, formattedSidebarString, 'utf-8');
Expand Down
4 changes: 2 additions & 2 deletions scripts/tasks/download-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const saveContents = async (files: Entry[], destination: string) => {
* @param options
*/
const downloadFromGitHub = async (
options: DownloadOptions
options: DownloadOptions,
): Promise<Entry[]> => {
const { org, repository, target, downloadMatch = '' } = options;

Expand Down Expand Up @@ -109,7 +109,7 @@ const downloadFromGitHub = async (
})
.on('finish', () => {
resolve(contents);
})
}),
);
});
});
Expand Down
46 changes: 23 additions & 23 deletions scripts/tasks/preprocess-api-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function findPossibleApiHistoryBlocks(tree: Root) {
(node as LiteralString).value.toLowerCase().includes('history'),
(node) => {
codeBlocks.push(node as Html);
}
},
);

return codeBlocks;
Expand All @@ -65,7 +65,7 @@ function findPossibleApiHistoryBlocks(tree: Root) {
function findValidApiHistoryBlocks(
possibleHistoryBlocks: Html[],
filePath: string,
validateAgainstSchema?: ValidateFunction<ApiHistory>
validateAgainstSchema?: ValidateFunction<ApiHistory>,
) {
const validHistoryBlocks: Html[] = [];

Expand All @@ -79,8 +79,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Error parsing possible history block (found null/undefined htmlComment) in ${logger.green(
filePath
)}`
filePath,
)}`,
);
continue;
}
Expand All @@ -89,8 +89,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Possible API History block is not in a HTML comment (${logger.green(
filePath
)})`
filePath,
)})`,
);
continue;
}
Expand All @@ -103,8 +103,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Error parsing possible history block (found null/undefined codeBlock) in ${logger.green(
filePath
)}`
filePath,
)}`,
);
continue;
}
Expand All @@ -117,8 +117,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Error parsing possible history block (codeBlock wasn't code, yaml, or history) in ${logger.green(
filePath
)}`
filePath,
)}`,
);
continue;
}
Expand All @@ -131,8 +131,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Error parsing YAML in possible history block (${logger.green(
filePath
)})`
filePath,
)})`,
);
continue;
}
Expand All @@ -144,8 +144,8 @@ function findValidApiHistoryBlocks(
hasWarned = true;
logger.warn(
`(Skipping block) Error validating YAML in possible history block (${logger.green(
filePath
)})`
filePath,
)})`,
);
continue;
}
Expand All @@ -166,12 +166,12 @@ export const preprocessApiHistory = async (startPath: string) => {
const ajv = new Ajv();
const ApiHistorySchemaFile = await readFile(schema, 'utf-8');
const ApiHistorySchema = JSON.parse(
ApiHistorySchemaFile
ApiHistorySchemaFile,
) as JSONSchemaType<ApiHistory>;
validateAgainstSchema = ajv.compile(ApiHistorySchema);
} catch (error) {
logger.warn(
`Error reading API history schema, continuing without schema validation:\n${error}`
`Error reading API history schema, continuing without schema validation:\n${error}`,
);
}

Expand All @@ -185,7 +185,7 @@ export const preprocessApiHistory = async (startPath: string) => {
const validHistoryBlocks = findValidApiHistoryBlocks(
possibleHistoryBlocks,
filePath,
validateAgainstSchema
validateAgainstSchema,
);

if (validHistoryBlocks.length === 0) continue;
Expand All @@ -202,8 +202,8 @@ export const preprocessApiHistory = async (startPath: string) => {
hasWarned = true;
logger.warn(
`(Skipping block) Error extracting the API history block inside HTML comment in ${logger.green(
filePath
)}`
filePath,
)}`,
);
continue;
}
Expand All @@ -217,18 +217,18 @@ export const preprocessApiHistory = async (startPath: string) => {
hasWarned = true;
logger.warn(
`(Skipping block) Error getting the start and end position of the API history block in ${logger.green(
filePath
)}`
filePath,
)}`,
);
continue;
}

const start = newContent.substring(
0,
validHistoryBlock.position.start.offset + fileLengthDifference
validHistoryBlock.position.start.offset + fileLengthDifference,
);
const end = newContent.substring(
validHistoryBlock.position.end.offset + fileLengthDifference
validHistoryBlock.position.end.offset + fileLengthDifference,
);

// Stripping the HTML comment tags of a history block will offset the position of the next history block
Expand Down
Loading

0 comments on commit 537aefb

Please sign in to comment.