Skip to content

Commit

Permalink
Merge pull request #217 from AndreaPontrandolfo/AndreaPontrandolfo/is…
Browse files Browse the repository at this point in the history
…sue216

fix(webservices): changed deploy webservices command
  • Loading branch information
AndreaPontrandolfo authored Aug 19, 2024
2 parents 8480caf + 30efcd1 commit 9cfa47a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/sheriff-webservices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/.eslintcache",
"typesync": "typesync --dry=fail",
"serve": "node ./dist/index.js",
"clean": "rm -rf .turbo dist"
"clean": "rm -rf .turbo dist node_modules/.cache"
},
"devDependencies": {
"@sherifforg/types": "workspace:*",
Expand Down
16 changes: 11 additions & 5 deletions apps/sheriff-webservices/src/getAllRules.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import type { ESLint } from 'eslint';
import arrowReturnStyle from 'eslint-plugin-arrow-return-style';
import astro from 'eslint-plugin-astro';
import fsecond from 'eslint-plugin-fsecond';
Expand All @@ -7,8 +9,7 @@ import jsdoc from 'eslint-plugin-jsdoc';
import reactAccessibility from 'eslint-plugin-jsx-a11y';
import lodashPlugin from 'eslint-plugin-lodash-f';
import playwright from 'eslint-plugin-playwright';
import jsxRuntime from 'eslint-plugin-react/configs/jsx-runtime.js';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
Expand All @@ -28,18 +29,23 @@ import type {
} from '@sherifforg/types';
import stylistic from '@stylistic/eslint-plugin';
import vitest from '@vitest/eslint-plugin';
import { prependRulesWithPluginName } from './prependRulesWithPluginName.js';

interface Plugin {
rules: Record<string, RuleOptions>;
}

export const getAllRules = (
settings: SheriffSettings,
prependRulesWithPluginName: (
rules: Record<string, RuleOptions> | ESLint.Plugin['rules'] | undefined,
pluginName: string,
) => Record<string, RuleOptions>,
): BarebonesConfigAtom['rules'] => {
const reactRulesCatalog = {
...reactRecommended.rules,
...jsxRuntime.rules,
//@ts-expect-error
...react.configs.flat.recommended.rules,
//@ts-expect-error
...react.configs.flat['jsx-runtime'].rules,
...prependRulesWithPluginName(reactAccessibility.rules, 'jsx-a11y'),
...prependRulesWithPluginName(reactHooks.rules, 'react-hooks'),
...prependRulesWithPluginName(reactRefresh.rules, 'react-refresh'),
Expand Down
6 changes: 5 additions & 1 deletion apps/sheriff-webservices/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { serve } from '@hono/node-server';
import type { BarebonesConfigAtom, SheriffSettings } from '@sherifforg/types';
import { generateRulesDataset } from './generateRulesDataset.js';
import { getAllRules } from './getAllRules.js';
import { prependRulesWithPluginName } from './prependRulesWithPluginName.js';

const app = new Hono();
const port = Number(process.env.PORT || 5001);
Expand All @@ -15,7 +16,10 @@ app.get('/api/keepalive', (context) => context.text('OK'));
app.post('/api/get-new-sheriff-config', async (context) => {
const userConfigChoices: SheriffSettings = await context.req.json();

const allRulesRaw = getAllRules(userConfigChoices);
const allRulesRaw = getAllRules(
userConfigChoices,
prependRulesWithPluginName,
);

const newConfig: BarebonesConfigAtom[] = getSheriffConfig(userConfigChoices);
const anyRuleAllowedConfig: BarebonesConfigAtom[] = getSheriffConfig(
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"playground": "pnpm --filter=cli-playground exec create-sheriff-config",
"playground:mimic-monorepo": "pnpm exec create-sheriff-config --filter=cli-playground",
"webservices:dev": "turbo run start --filter=sheriff-webservices",
"webservices:deploy": "turbo run serve --filter=sheriff-webservices",
"preview-docs": "turbo run serve --filter=docs-website",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo run lint",
Expand All @@ -18,7 +19,7 @@
"validate-config": "turbo run validate-config",
"merge-checks": "turbo run publint manypkg typesync knip typecheck lint validate-config check-deduped-deps",
"check-deduped-deps": "pnpm dedupe --check",
"clean": "turbo run clean",
"clean": "turbo run clean && rm -rf .turbo",
"delete-node-modules": "pnpm exec rm -rf node_modules && pnpm -r exec rm -rf node_modules",
"nuke": "pnpm clean && pnpm delete-node-modules",
"reset-node-modules-and-lockfile": "pnpm delete-node-modules && pnpm exec rm -rf ./pnpm-lock.yaml && pnpm i",
Expand Down
3 changes: 2 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
},
"serve": {
"cache": false,
"persistent": true
"persistent": true,
"dependsOn": ["build"]
},
"check-deduped-deps": {
"inputs": [
Expand Down

0 comments on commit 9cfa47a

Please sign in to comment.