Skip to content

Commit

Permalink
tgui: prettierx -> prettier, fix dev server (Monkestation#2418)
Browse files Browse the repository at this point in the history
* Replaces prettierx with the normal prettier

* Fix tgui dev server
  • Loading branch information
Absolucy authored Jun 26, 2024
1 parent 2c5cc7e commit e87eb95
Show file tree
Hide file tree
Showing 585 changed files with 7,267 additions and 4,430 deletions.
38 changes: 27 additions & 11 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"eslint.nodePath": "./tgui/.yarn/sdks",
"eslint.workingDirectories": ["./tgui"],
"prettier.prettierPath": "./tgui/.yarn/sdks/prettier/index.js",
"eslint.workingDirectories": [
"./tgui"
],
"prettier.prettierPath": "./tgui/.yarn/sdks/prettier/index.cjs",
"typescript.tsdk": "./tgui/.yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"search.exclude": {
Expand All @@ -13,36 +15,50 @@
},
"files.eol": "\n",
"files.insertFinalNewline": true,
"git.branchProtection": ["master"],
"gitlens.advanced.blame.customArguments": ["-w"],
"gitlens.advanced.blame.customArguments": [
"-w"
],
"tgstationTestExplorer.project.resultsType": "json",
"[javascript]": {
"editor.rulers": [80],
"editor.rulers": [
80
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[javascriptreact]": {
"editor.rulers": [80],
"editor.rulers": [
80
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.rulers": [80],
"editor.rulers": [
80
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescriptreact]": {
"editor.rulers": [80],
"editor.rulers": [
80
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[scss]": {
"editor.rulers": [80],
"editor.rulers": [
80
],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"workbench.editorAssociations": {
"*.dmi": "dmiEditor.dmiEditor"
},
"Lua.diagnostics.enable": false
}
"Lua.diagnostics.enable": false,
"git.branchProtection": [
"master"
]
}
14 changes: 0 additions & 14 deletions tgui/.prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
arrowParens: always
breakLongMethodChains: true
endOfLine: lf
importFormatting: oneline
jsxBracketSameLine: true
jsxSingleQuote: false
offsetTernaryExpressions: true
printWidth: 80
proseWrap: preserve
quoteProps: preserve
semi: true
singleQuote: true
tabWidth: 2
trailingComma: es5
useTabs: false
5 changes: 4 additions & 1 deletion tgui/.yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
"name": "eslint",
"version": "7.32.0-sdk",
"main": "./lib/api.js",
"type": "commonjs"
"type": "commonjs",
"bin": {
"eslint": "./bin/eslint.js"
}
}
20 changes: 20 additions & 0 deletions tgui/.yarn/sdks/prettier/bin/prettier.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire} = require(`module`);
const {resolve} = require(`path`);

const relPnpApiPath = "../../../../.pnp.cjs";

const absPnpApiPath = resolve(__dirname, relPnpApiPath);
const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/bin/prettier.cjs
require(absPnpApiPath).setup();
}
}

// Defer to the real prettier/bin/prettier.cjs your application uses
module.exports = absRequire(`prettier/bin/prettier.cjs`);
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require prettier/index.js
// Setup the environment to be able to require prettier
require(absPnpApiPath).setup();
}
}

// Defer to the real prettier/index.js your application uses
module.exports = absRequire(`prettier/index.js`);
// Defer to the real prettier your application uses
module.exports = absRequire(`prettier`);
7 changes: 4 additions & 3 deletions tgui/.yarn/sdks/prettier/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "prettier",
"version": "0.19.0-sdk",
"main": "./index.js",
"type": "commonjs"
"version": "3.1.0-sdk",
"main": "./index.cjs",
"type": "commonjs",
"bin": "./bin/prettier.cjs"
}
2 changes: 2 additions & 0 deletions tgui/.yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
2 changes: 2 additions & 0 deletions tgui/.yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tgui/.yarn/sdks/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/typescript.js
// Setup the environment to be able to require typescript
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/lib/typescript.js your application uses
module.exports = absRequire(`typescript/lib/typescript.js`);
// Defer to the real typescript your application uses
module.exports = absRequire(`typescript`);
6 changes: 5 additions & 1 deletion tgui/.yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"name": "typescript",
"version": "4.9.4-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
"type": "commonjs",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
}
}
4 changes: 2 additions & 2 deletions tgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"tgui:build": "BROWSERSLIST_IGNORE_OLD_DATA=true webpack",
"tgui:dev": "node --experimental-modules packages/tgui-dev-server/index.js",
"tgui:lint": "eslint packages --ext .js,.cjs,.ts,.tsx",
"tgui:prettier": "prettierx --check .",
"tgui:prettier": "prettier --check .",
"tgui:sonar": "eslint packages --ext .js,.cjs,.ts,.tsx -c .eslintrc-sonar.yml",
"tgui:test": "jest --watch",
"tgui:test-simple": "CI=true jest --color",
Expand Down Expand Up @@ -49,7 +49,7 @@
"jest-circus": "^27.0.6",
"jsdom": "^16.7.0",
"mini-css-extract-plugin": "^1.6.2",
"prettier": "npm:[email protected].0",
"prettier": "^3.1.0",
"sass": "^1.37.5",
"sass-loader": "^11.1.1",
"style-loader": "^2.0.0",
Expand Down
12 changes: 6 additions & 6 deletions tgui/packages/common/collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export const filter =
};

type MapFunction = {
<T, U>(iterateeFn: (value: T, index: number, collection: T[]) => U): (
collection: T[]
) => U[];
<T, U>(
iterateeFn: (value: T, index: number, collection: T[]) => U,
): (collection: T[]) => U[];

<T, U, K extends string | number>(
iterateeFn: (value: T, index: K, collection: Record<K, T>) => U
iterateeFn: (value: T, index: K, collection: Record<K, T>) => U,
): (collection: Record<K, T>) => U[];
};

Expand Down Expand Up @@ -75,7 +75,7 @@ export const map: MapFunction =
*/
export const filterMap = <T, U>(
collection: T[],
iterateeFn: (value: T) => U | undefined
iterateeFn: (value: T) => U | undefined,
): U[] => {
const finalCollection: U[] = [];

Expand Down Expand Up @@ -261,7 +261,7 @@ export const zipWith =
const binarySearch = <T, U = unknown>(
getKey: (value: T) => U,
collection: readonly T[],
inserting: T
inserting: T,
): number => {
if (collection.length === 0) {
return 0;
Expand Down
12 changes: 6 additions & 6 deletions tgui/packages/common/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Color {
this.r - this.r * percent,
this.g - this.g * percent,
this.b - this.b * percent,
this.a
this.a,
);
}

Expand All @@ -47,7 +47,7 @@ export class Color {
return new Color(
parseInt(hex.substr(1, 2), 16),
parseInt(hex.substr(3, 2), 16),
parseInt(hex.substr(5, 2), 16)
parseInt(hex.substr(5, 2), 16),
);
}

Expand All @@ -59,7 +59,7 @@ export class Color {
(c2.r - c1.r) * n + c1.r,
(c2.g - c1.g) * n + c1.g,
(c2.b - c1.b) * n + c1.b,
(c2.a - c1.a) * n + c1.a
(c2.a - c1.a) * n + c1.a,
);
}

Expand Down Expand Up @@ -102,7 +102,7 @@ export class Color {
const round = (
number: number,
digits = 0,
base = Math.pow(10, digits)
base = Math.pow(10, digits),
): number => {
return Math.round(base * number) / base;
};
Expand Down Expand Up @@ -222,7 +222,7 @@ export const hsvaToHsla = ({ h, s, v, a }: HsvaColor): HslaColor => {
s: round(
hh > 0 && hh < 200
? ((s * v) / 100 / (hh <= 100 ? hh : 200 - hh)) * 100
: 0
: 0,
),
l: round(hh / 2),
a: round(a, 2),
Expand Down Expand Up @@ -386,7 +386,7 @@ export const luminance = (rgb: RgbColor): number => {

export const contrast = (
foreground: RgbColor,
background: RgbColor
background: RgbColor,
): number => {
const foreground_luminance = luminance(foreground);
const background_luminance = luminance(background);
Expand Down
11 changes: 9 additions & 2 deletions tgui/packages/common/redux.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { Action, Reducer, applyMiddleware, combineReducers, createAction, createStore } from './redux';
import {
Action,
Reducer,
applyMiddleware,
combineReducers,
createAction,
createStore,
} from './redux';

// Dummy Reducer
const counterReducer: Reducer<number, Action<string>> = (state = 0, action) => {
Expand Down Expand Up @@ -31,7 +38,7 @@ describe('Redux implementation tests', () => {
test('createStore with applyMiddleware works', () => {
const store = createStore(
counterReducer,
applyMiddleware(loggingMiddleware)
applyMiddleware(loggingMiddleware),
);
expect(store.getState()).toBe(0);
});
Expand Down
Loading

0 comments on commit e87eb95

Please sign in to comment.