Skip to content

Commit

Permalink
chore: eslint config
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfran committed Mar 12, 2024
1 parent b535718 commit 92a2645
Show file tree
Hide file tree
Showing 32 changed files with 218 additions and 81 deletions.
59 changes: 57 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,63 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {}
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@nx/typescript",
"plugin:deprecation/recommended",
"prettier"
],
"rules": {
"@typescript-eslint/no-unused-vars": ["error"],
"no-multiple-empty-lines": [
2,
{
"max": 1
}
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
]
}
},
{
"files": ["*.spec.ts"],
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"plugin:@nx/typescript",
"plugin:deprecation/recommended",
"prettier"
],
"rules": {

"@typescript-eslint/no-unused-vars": ["error"],
"no-multiple-empty-lines": [
2,
{
"max": 1
}
],
"quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@ngrx/prefix-selectors-with-select": "off"
}
},
{
"files": ["*.js", "*.jsx"],
Expand Down
6 changes: 5 additions & 1 deletion apps/contrast-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "vite.config.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./apps/contrast-plugin/tsconfig.app.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
21 changes: 0 additions & 21 deletions apps/contrast-plugin/src/app/app.element.spec.ts

This file was deleted.

1 change: 1 addition & 0 deletions apps/contrast-plugin/src/app/app.element.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import 'plugins-styles/lib/styles.css';
import './app.element.css';

Expand Down
4 changes: 4 additions & 0 deletions apps/contrast-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ penpot.ui.onMessage<{ content: string }>((message) => {
const pageState = penpot.getPageState();
const fileState = penpot.getFileState();

if (!pageState || !fileState) {
return;
}

penpot.ui.sendMessage({
type: 'init',
content: {
Expand Down
6 changes: 5 additions & 1 deletion apps/example-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "vite.config.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./apps/example-plugin/tsconfig.app.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
1 change: 1 addition & 0 deletions apps/example-plugin/src/app/app.element.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import 'plugins-styles/lib/styles.css';
import './app.element.css';

Expand Down
6 changes: 5 additions & 1 deletion apps/example-styles/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "vite.config.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./apps/example-styles/tsconfig.app.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
4 changes: 4 additions & 0 deletions apps/rpc-api/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./apps/rpc-api/tsconfig.app.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
6 changes: 3 additions & 3 deletions apps/rpc-api/src/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import AutoLoad from '@fastify/autoload';
/* eslint-disable-next-line */
export interface AppOptions {}

export async function app(fastify: FastifyInstance, opts: AppOptions) {
export function app(fastify: FastifyInstance, opts: AppOptions) {
fastify;

// This loads all plugins defined in plugins
// those should be support plugins that are reused
// through your application
fastify.register(AutoLoad, {
void fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
options: { ...opts },
});

// This loads all plugins defined in routes
// define your routes in one of these
fastify.register(AutoLoad, {
void fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
options: { ...opts },
});
Expand Down
4 changes: 2 additions & 2 deletions apps/rpc-api/src/app/plugins/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import { FastifyInstance } from 'fastify';
import fp from 'fastify-plugin';
import cors from '@fastify/cors';

export default fp(async function (fastify: FastifyInstance) {
fastify.register(cors);
export default fp(function (fastify: FastifyInstance) {
void fastify.register(cors);
});
4 changes: 2 additions & 2 deletions apps/rpc-api/src/app/plugins/sensible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import sensible from '@fastify/sensible';
*
* @see https://github.com/fastify/fastify-sensible
*/
export default fp(async function (fastify: FastifyInstance) {
fastify.register(sensible);
export default fp(function (fastify: FastifyInstance) {
void fastify.register(sensible);
});
5 changes: 3 additions & 2 deletions apps/rpc-api/src/app/routes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { v4 } from 'uuid';

const token = process.env.ACCESS_TOKEN;

export default async function (fastify: FastifyInstance) {
export default function (fastify: FastifyInstance) {
const apiUrl = process.env.API_URL + '/api/rpc/command';
const fakeSessionId = v4();

Expand Down Expand Up @@ -97,7 +97,8 @@ export default async function (fastify: FastifyInstance) {
)
.then((data) => {
console.log('Success:', data);
reply.send(data);

return reply.send(data);
})
.catch((error) => {
console.error('Error:', error);
Expand Down
2 changes: 1 addition & 1 deletion apps/rpc-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const server = Fastify({
});

// Register your application as a normal plugin.
server.register(app);
void server.register(app);

// Start listening.
server.listen({ port, host }, (err) => {
Expand Down
9 changes: 9 additions & 0 deletions docs/create-app-lib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Every time a project or library is created the `typescript-eslint/parser` must be added.

```json
"ignorePatterns": ["!**/*", "vite.config.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./apps/app-name/tsconfig.app.json"
},
```
6 changes: 5 additions & 1 deletion libs/plugins-data-parser/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"ignorePatterns": ["!**/*", "vite.config.ts"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./libs/plugins-data-parser/tsconfig.lib.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
4 changes: 2 additions & 2 deletions libs/plugins-data-parser/src/lib/models/parsed.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export interface Option {
position: number;
frameId: string;
id: string;
axis: null | unknown;
x: null | unknown;
axis: unknown;
x: unknown;
}

export interface Components {
Expand Down
2 changes: 1 addition & 1 deletion libs/plugins-data-parser/src/lib/models/selection.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface CljValues {
export interface UnderscoreValues {
__meta?: null | number;
__extmap?: null | number;
__hash: number | number;
__hash: null | number;
}

export interface NilValues {
Expand Down
2 changes: 1 addition & 1 deletion libs/plugins-data-parser/src/lib/utils/parse-arr.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function parseArrProperty(
*/
export function parseObjArr(obj: unknown): unknown {
if (isSingleObjectWithProperty(obj, 'arr')) {
return parseArrProperty((obj as Arr)['arr'] as unknown[]);
return parseArrProperty((obj as Arr)['arr']);
}

return obj;
Expand Down
6 changes: 5 additions & 1 deletion libs/plugins-data-parser/src/lib/utils/selected.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ import { UnparsedSelection } from '../models/selection.model';
export function getSelectedUuids(selection: UnparsedSelection): string[] {
const root = selection?.linked_map?.delegate_map?.root?.arr;

return (root?.filter((r) => r?.uuid).map((r) => r.uuid) as string[]) || [];
if (!root) {
return [];
}

return root.map((r) => r.uuid).filter((uuid): uuid is string => !!uuid);
}
25 changes: 10 additions & 15 deletions libs/plugins-data-parser/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"types": ["vite/client"],
"noEmit": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"esModuleInterop": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": ["src"],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
22 changes: 22 additions & 0 deletions libs/plugins-data-parser/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
4 changes: 4 additions & 0 deletions libs/plugins-runtime/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./libs/plugins-runtime/tsconfig.*?.json"
},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
Expand Down
4 changes: 1 addition & 3 deletions libs/plugins-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ export function initialize(api: any) {

console.log(api);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
/* eslint-disable */
api.addListener('plugin-page', 'page', (page: any) => {
console.log('Page Changed:', page);

setPageState(page);
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
api.addListener('plugin-file', 'file', (file: any) => {
console.log('File Changed:', file);

setFileState(file);
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
api.addListener('plugin-selection', 'selection', (selection: any) => {
const selectionData = getSelectedUuids(selection);
console.log('Selection Changed:', selectionData);
Expand Down
Loading

0 comments on commit 92a2645

Please sign in to comment.