Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all",
"semi": false,
"semi": true,
"importOrder": [
"<BUILTIN_MODULES>",
"^(react/(.*)$)|^(react$)",
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ yarn add react-mindee-js
You only need an image and a list of shapes to get started.

```jsx
import React from 'react'
import dummyImage from 'path-to-your/file.jpg'
import { AnnotationViewer } from 'react-mindee-js'
import React from 'react';
import dummyImage from 'path-to-your/file.jpg';
import { AnnotationViewer } from 'react-mindee-js';

const dummyShapes = [
{
Expand All @@ -67,15 +67,15 @@ const dummyShapes = [
[0.394, 0.087],
],
},
]
];

const data = {
image: dummyImage,
shapes: dummyShapes,
}
};

function App() {
return <AnnotationViewer data={data} />
return <AnnotationViewer data={data} />;
}
```

Expand Down
15 changes: 7 additions & 8 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { addMatchImageSnapshotPlugin } from '@simonsmith/cypress-image-snapshot/plugin'
import { defineConfig } from 'cypress'
import { defineConfig as defineViteConfig } from 'vite'
import tsconfigPaths from 'vite-tsconfig-paths'
import { addMatchImageSnapshotPlugin } from '@simonsmith/cypress-image-snapshot/plugin';
import { defineConfig } from 'cypress';
import { defineConfig as defineViteConfig } from 'vite';

export default defineConfig({
viewportWidth: 1500,
Expand All @@ -17,18 +16,18 @@ export default defineConfig({
// if (config.testingType === 'component')
// on('dev-server:start', async (options) => startDevServer({ options }))

addMatchImageSnapshotPlugin(on)
addMatchImageSnapshotPlugin(on);

return config
return config;
},
specPattern: 'src/**/*.spec.{js,ts,jsx,tsx}',
devServer: {
framework: 'react',
bundler: 'vite',
viteConfig: defineViteConfig({
assetsInclude: ['**/*.tiff', '**/*.heic'],
plugins: [tsconfigPaths()],
resolve: { tsconfigPaths: true },
}),
},
},
})
});
4 changes: 2 additions & 2 deletions cypress/assets/shapes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnnotationShape } from '@/index'
import type { AnnotationShape } from '@/index';

export const dummyShapes: AnnotationShape[] = [
{
Expand Down Expand Up @@ -46,4 +46,4 @@ export const dummyShapes: AnnotationShape[] = [
[0.625, 0.706],
],
},
]
];
8 changes: 4 additions & 4 deletions cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { addMatchImageSnapshotCommand } from '@simonsmith/cypress-image-snapshot/command'
import { mount } from 'cypress/react'
import { addMatchImageSnapshotCommand } from '@simonsmith/cypress-image-snapshot/command';
import { mount } from 'cypress/react';

addMatchImageSnapshotCommand({
failureThreshold: 0.2,
failureThresholdType: 'percent',
capture: 'runner',
})
Cypress.Commands.add('mount', mount)
});
Cypress.Commands.add('mount', mount);
4 changes: 2 additions & 2 deletions cypress/support/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { mount } from 'cypress/react'
import type { mount } from 'cypress/react';

declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
mount: typeof mount;
}
}
}
98 changes: 89 additions & 9 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import js from '@eslint/js'
import prettier from 'eslint-config-prettier'
import reactHooks from 'eslint-plugin-react-hooks'
import { defineConfig } from 'eslint/config'
import globals from 'globals'
import tseslint from 'typescript-eslint'
import js from '@eslint/js';
import prettier from 'eslint-config-prettier';
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default defineConfig(
{ ignores: ['dist', 'docs', 'node_modules', 'cypress/snapshots'] },
Expand All @@ -12,6 +12,9 @@ export default defineConfig(
tseslint.configs.stylisticTypeChecked,
reactHooks.configs.flat['recommended-latest'],
{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
languageOptions: {
globals: { ...globals.browser, ...globals.es2022 },
parserOptions: {
Expand All @@ -20,19 +23,86 @@ export default defineConfig(
},
},
rules: {
// --- typing strictness (beyond strictTypeChecked) ---
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/ban-ts-comment': [
'error',
{ 'ts-expect-error': 'allow-with-description' },
],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/explicit-function-return-type': [
'error',
{
allowExpressions: true,
allowTypedFunctionExpressions: true,
allowHigherOrderFunctions: true,
allowIIFEs: true,
},
],
'@typescript-eslint/explicit-module-boundary-types': 'error',
'@typescript-eslint/strict-boolean-expressions': 'error',
Comment thread
sebastianMindee marked this conversation as resolved.
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/promise-function-async': 'error',
'@typescript-eslint/return-await': ['error', 'always'],
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/method-signature-style': 'error',

// --- module hygiene ---
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/consistent-type-exports': 'error',
'@typescript-eslint/no-import-type-side-effects': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['../*'],
message:
'Use the @/ path alias instead of relative parent paths.',
},
],
},
],

// --- naming & scoping ---
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', ignoreRestSiblings: true },
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'default',
format: ['camelCase'],
leadingUnderscore: 'allow',
},
{
selector: 'variable',
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
},
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
{ selector: 'typeLike', format: ['PascalCase'] },
{ selector: 'enumMember', format: ['PascalCase', 'UPPER_CASE'] },
// Konva/DOM/third-party config keys are dictated by their APIs.
{ selector: ['objectLiteralProperty', 'typeProperty'], format: null },
{ selector: 'import', format: null },
],

// --- base rules (mirrors mindee-api-nodejs where not covered by Prettier) ---
eqeqeq: 'error',
'no-eval': 'error',
'no-else-return': 'error',
'no-nested-ternary': 'error',
'no-implicit-coercion': 'error',
'no-param-reassign': 'error',
'default-case-last': 'error',
'prefer-template': 'error',
'object-shorthand': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
},
},
Expand All @@ -45,11 +115,21 @@ export default defineConfig(
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
},
},
{
// Declaration merging (e.g. augmenting Cypress.Chainable) requires interfaces.
files: ['**/*.d.ts'],
rules: { '@typescript-eslint/consistent-type-definitions': 'off' },
},
{
files: ['*.config.ts'],
languageOptions: { globals: globals.node },
},
prettier,
)
{
rules: { curly: ['error', 'all'] },
},
);
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"typescript": "^6.0.3",
"typescript-eslint": "^8.71.0",
"vite": "^8.3.1",
"vite-plugin-dts": "^5.1.1",
"vite-tsconfig-paths": "^6.1.1"
"vite-plugin-dts": "^5.1.1"
},
"peerDependencies": {
"react": "^18 || ^19",
Expand All @@ -82,7 +81,7 @@
"docs:deploy": "pnpm --dir ./docs deploy",
"prettier:check": "prettier --check .",
"prettier:write": "prettier --write .",
"lint": "tsc --noEmit && eslint . && prettier --check .",
"lint": "tsc --noEmit && eslint --max-warnings 0 . && prettier --check .",
"lint:fix": "eslint --fix . && prettier --write ."
},
"keywords": [
Expand Down
38 changes: 0 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading