Skip to content

Commit

Permalink
Introduce Prettier (#1198)
Browse files Browse the repository at this point in the history
* Prettier js files only

* Run prettier

* Add trailingComma

* Add prettier package and lint

* Disable formatting rules

* Run rules

* Fix web-compat lint rules and add back template string checking

* Rerun

* Run from npx

* Fix some merge errors

* Update lint config

* Apply prettier on remaining files

* Apply prettier after merge

* Do not run prettier on generated files

* Fix a test and pin to a tagged version of eslint-config

* Fix prettier on windows

* Enforce semicolons

* Add semicolons (prettier)

* Ignore .vscode

---------

Co-authored-by: Maxim Tsoy <maks.tsoy@gmail.com>
  • Loading branch information
jonathanKingston and muodov authored Nov 6, 2024
1 parent 443a70a commit 53818cc
Show file tree
Hide file tree
Showing 370 changed files with 18,465 additions and 18,363 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/locales/** linguist-generated
src/types/* text eol=lf
* text=auto eol=lf
68 changes: 34 additions & 34 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
target-branch: "main"
open-pull-requests-limit: 20
labels:
- "dependencies"
groups:
eslint:
patterns:
- "eslint*"
- "@typescript-eslint*"
stylelint:
patterns:
- "stylelint*"
typescript:
patterns:
- "typedoc"
- "typescript"
- "@types/*"
- "@typescript-eslint*"
rollup:
patterns:
- "@rollup/*"
- "rollup-*"
- "rollup"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "main"
labels:
- "dependencies"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'daily'
target-branch: 'main'
open-pull-requests-limit: 20
labels:
- 'dependencies'
groups:
eslint:
patterns:
- 'eslint*'
- '@typescript-eslint*'
stylelint:
patterns:
- 'stylelint*'
typescript:
patterns:
- 'typedoc'
- 'typescript'
- '@types/*'
- '@typescript-eslint*'
rollup:
patterns:
- '@rollup/*'
- 'rollup-*'
- 'rollup'
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
target-branch: 'main'
labels:
- 'dependencies'
138 changes: 69 additions & 69 deletions .github/scripts/diff-directories.js
Original file line number Diff line number Diff line change
@@ -1,124 +1,124 @@
import fs from 'fs'
import path from 'path'
import fs from 'fs';
import path from 'path';

function readFilesRecursively (directory) {
const filenames = fs.readdirSync(directory)
const files = {}
function readFilesRecursively(directory) {
const filenames = fs.readdirSync(directory);
const files = {};

filenames.forEach((filename) => {
const filePath = path.join(directory, filename)
const fileStats = fs.statSync(filePath)
const filePath = path.join(directory, filename);
const fileStats = fs.statSync(filePath);

if (fileStats.isDirectory()) {
const nestedFiles = readFilesRecursively(filePath)
const nestedFiles = readFilesRecursively(filePath);
for (const [nestedFilePath, nestedFileContent] of Object.entries(nestedFiles)) {
files[path.join(filename, nestedFilePath)] = nestedFileContent
files[path.join(filename, nestedFilePath)] = nestedFileContent;
}
} else {
files[filename] = fs.readFileSync(filePath, 'utf-8')
files[filename] = fs.readFileSync(filePath, 'utf-8');
}
})
});

return files
return files;
}

function upperCaseFirstLetter (string) {
return string.charAt(0).toUpperCase() + string.slice(1)
function upperCaseFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

function displayDiffs (dir1Files, dir2Files, isOpen) {
const rollupGrouping = {}
function displayDiffs(dir1Files, dir2Files, isOpen) {
const rollupGrouping = {};
/**
* Rolls up multiple files with the same diff into a single entry
* @param {string} fileName
* @param {string} string
* @param {string} fileName
* @param {string} string
* @param {string} [summary]
*/
function add(fileName, string, summary = undefined) {
if (summary === undefined) {
summary = string
summary = string;
}
if (!(summary in rollupGrouping)) {
rollupGrouping[summary] = { files: [] }
rollupGrouping[summary] = { files: [] };
}
rollupGrouping[summary].files.push(fileName)
rollupGrouping[summary].string = string
rollupGrouping[summary].files.push(fileName);
rollupGrouping[summary].string = string;
}
for (const [filePath, fileContent] of Object.entries(dir1Files)) {
let diffOut = ''
let compareOut
let diffOut = '';
let compareOut;
if (filePath in dir2Files) {
const fileOut = fileContent
const file2Out = dir2Files[filePath]
delete dir2Files[filePath]
const fileOut = fileContent;
const file2Out = dir2Files[filePath];
delete dir2Files[filePath];
if (fileOut === file2Out) {
continue
continue;
} else {
compareOut = filePath.split('/')[0]
diffOut = `File has changed`
compareOut = filePath.split('/')[0];
diffOut = `File has changed`;
}
} else {
diffOut = '❌ File only exists in old changeset'
compareOut = 'Removed Files'
diffOut = '❌ File only exists in old changeset';
compareOut = 'Removed Files';
}
add(filePath, diffOut, compareOut)
add(filePath, diffOut, compareOut);
}

for (const filePath of Object.keys(dir2Files)) {
add(filePath, '❌ File only exists in new changeset', 'New Files')
add(filePath, '❌ File only exists in new changeset', 'New Files');
}
const outString = Object.keys(rollupGrouping).map(key => {
const rollup = rollupGrouping[key]
let outString = `
`
const title = key
if (rollup.files.length) {
for (const file of rollup.files) {
outString += `- ${file}\n`
const outString = Object.keys(rollupGrouping)
.map((key) => {
const rollup = rollupGrouping[key];
let outString = `
`;
const title = key;
if (rollup.files.length) {
for (const file of rollup.files) {
outString += `- ${file}\n`;
}
}
}
outString += '\n\n' + rollup.string
return renderDetails(title, outString, isOpen)
}).join('\n')
return outString
outString += '\n\n' + rollup.string;
return renderDetails(title, outString, isOpen);
})
.join('\n');
return outString;
}

function renderDetails (section, text, isOpen) {
function renderDetails(section, text, isOpen) {
if (section === 'dist') {
section = 'apple'
section = 'apple';
}
const open = section !== 'integration' ? 'open' : ''
const open = section !== 'integration' ? 'open' : '';
return `<details ${open}>
<summary>${upperCaseFirstLetter(section)}</summary>
${text}
</details>`
</details>`;
}

if (process.argv.length !== 4) {
console.error('Usage: node diff_directories.js <directory1> <directory2>')
process.exit(1)
console.error('Usage: node diff_directories.js <directory1> <directory2>');
process.exit(1);
}

const dir1 = process.argv[2]
const dir2 = process.argv[3]
const dir1 = process.argv[2];
const dir2 = process.argv[3];

const sections = {
}
function sortFiles (dirFiles, dirName) {
const sections = {};
function sortFiles(dirFiles, dirName) {
for (const [filePath, fileContent] of Object.entries(dirFiles)) {
sections[dirName] = sections[dirName] || {}
sections[dirName][filePath] = fileContent
sections[dirName] = sections[dirName] || {};
sections[dirName][filePath] = fileContent;
}
}

const buildDir = '/build'
const sourcesOutput = '/Sources/ContentScopeScripts/'
sortFiles(readFilesRecursively(dir1 + buildDir), 'dir1')
sortFiles(readFilesRecursively(dir2 + buildDir), 'dir2')
sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1')
sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2')

const buildDir = '/build';
const sourcesOutput = '/Sources/ContentScopeScripts/';
sortFiles(readFilesRecursively(dir1 + buildDir), 'dir1');
sortFiles(readFilesRecursively(dir2 + buildDir), 'dir2');
sortFiles(readFilesRecursively(dir1 + sourcesOutput), 'dir1');
sortFiles(readFilesRecursively(dir2 + sourcesOutput), 'dir2');

// console.log(Object.keys(files))
const fileOut = displayDiffs(sections.dir1, sections.dir2, true)
console.log(fileOut)
const fileOut = displayDiffs(sections.dir1, sections.dir2, true);
console.log(fileOut);
38 changes: 19 additions & 19 deletions .github/workflows/asana.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
name: 'asana sync'
on:
pull_request_review:
pull_request_target:
types:
- opened
- edited
- closed
- reopened
- synchronize
- review_requested
pull_request_review:
pull_request_target:
types:
- opened
- edited
- closed
- reopened
- synchronize
- review_requested

jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: sammacbeth/action-asana-sync@v6
with:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
ASANA_WORKSPACE_ID: ${{ secrets.ASANA_WORKSPACE_ID }}
ASANA_PROJECT_ID: '1208598406046969'
USER_MAP: ${{ vars.USER_MAP }}
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: sammacbeth/action-asana-sync@v6
with:
ASANA_ACCESS_TOKEN: ${{ secrets.ASANA_ACCESS_TOKEN }}
ASANA_WORKSPACE_ID: ${{ secrets.ASANA_WORKSPACE_ID }}
ASANA_PROJECT_ID: '1208598406046969'
USER_MAP: ${{ vars.USER_MAP }}
Loading

0 comments on commit 53818cc

Please sign in to comment.