From 8b8e7d8aed037f1365b9c299e05d6c8acda26f48 Mon Sep 17 00:00:00 2001 From: Kevin Miller Date: Tue, 30 Apr 2024 07:30:52 -0700 Subject: [PATCH] chore: linting --- .eslintrc.js | 6 ++-- .github/workflows/test.yml | 3 ++ frontend/components/form/configure-field.tsx | 1 - frontend/components/form/table-select.tsx | 2 +- .../generators/attachment.test.ts | 1 - .../generators/attachment.tsx | 2 +- .../generators/checkbox.test.tsx | 2 -- .../random-generator/generators/duration.tsx | 2 -- .../random-generator/generators/select.tsx | 4 +-- .../components/hook/random-generator/index.ts | 3 -- frontend/types.d.ts | 1 + package-lock.json | 30 +++++++++++++++++-- package.json | 1 + 13 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1703a68..a835cac 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,6 +2,7 @@ module.exports = { env: { browser: true, es6: true, + 'jest/globals': true, }, extends: ['eslint:recommended', 'plugin:react/recommended'], globals: { @@ -16,9 +17,10 @@ module.exports = { ecmaVersion: 2018, sourceType: 'module', }, - plugins: ['@typescript-eslint', 'react', 'react-hooks'], + plugins: ['@typescript-eslint', 'react', 'react-hooks', 'jest'], rules: { - 'no-unused-vars': 'off', + 'no-undef': 0, + 'no-unused-vars': 0, '@typescript-eslint/no-unused-vars': 'error', 'react/prop-types': 0, 'react-hooks/rules-of-hooks': 'error', diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2b1e7e..b95513e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,3 +14,6 @@ jobs: - name: Test run: npm run test + + - name: Lint + run: npm run lint diff --git a/frontend/components/form/configure-field.tsx b/frontend/components/form/configure-field.tsx index 3a1ecc1..4a0d17f 100644 --- a/frontend/components/form/configure-field.tsx +++ b/frontend/components/form/configure-field.tsx @@ -113,7 +113,6 @@ const ConfigureField: React.FC = ({ )} ) - return null } export default ConfigureField diff --git a/frontend/components/form/table-select.tsx b/frontend/components/form/table-select.tsx index 4fcca99..332d7de 100644 --- a/frontend/components/form/table-select.tsx +++ b/frontend/components/form/table-select.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { TablePicker, FormField, Box } from '@airtable/blocks/ui' +import { TablePicker, FormField } from '@airtable/blocks/ui' import { Table } from '@airtable/blocks/models' import Alert from '../common/alert' diff --git a/frontend/components/hook/random-generator/generators/attachment.test.ts b/frontend/components/hook/random-generator/generators/attachment.test.ts index 626ce68..f0a8a60 100644 --- a/frontend/components/hook/random-generator/generators/attachment.test.ts +++ b/frontend/components/hook/random-generator/generators/attachment.test.ts @@ -1,4 +1,3 @@ -import TestDriver from '@airtable/blocks-testing' import '@testing-library/jest-dom' import attachmentGenerators from './attachment' diff --git a/frontend/components/hook/random-generator/generators/attachment.tsx b/frontend/components/hook/random-generator/generators/attachment.tsx index 4126af7..0c1cb8d 100644 --- a/frontend/components/hook/random-generator/generators/attachment.tsx +++ b/frontend/components/hook/random-generator/generators/attachment.tsx @@ -58,7 +58,7 @@ const image: RandomGenerator = { generate: ({ options }) => [ { url: faker.image.urlLoremFlickr({ category: options.category }) }, ], - preview: ({ options, field }) => ( + preview: ({ options }) => ( + generate: ({ field }) => field.options.choices[ Math.floor(Math.random() * field.options.choices.length) ], @@ -34,7 +34,7 @@ const multipleSelect: RandomGenerator = { return ( <> {choices.map((choice) => ( - + ))} ) diff --git a/frontend/components/hook/random-generator/index.ts b/frontend/components/hook/random-generator/index.ts index 4c23cd1..b42b110 100644 --- a/frontend/components/hook/random-generator/index.ts +++ b/frontend/components/hook/random-generator/index.ts @@ -1,4 +1,3 @@ -import { useBase } from '@airtable/blocks/ui' import { FieldType, Field, Base } from '@airtable/blocks/models' import generators from './generators' @@ -6,8 +5,6 @@ import generators from './generators' * A hook that returns random generator functions. */ const useRandomGenerator = () => { - const base = useBase() - const getGenerators = (): RandomGenerator[] => generators /** diff --git a/frontend/types.d.ts b/frontend/types.d.ts index f85da2a..c4c7273 100644 --- a/frontend/types.d.ts +++ b/frontend/types.d.ts @@ -1,3 +1,4 @@ +import React from 'react' import { FieldType, Field, Base } from '@airtable/blocks/models' interface GenerateOptions { diff --git a/package-lock.json b/package-lock.json index c926afd..f9e6963 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "airtable-extension-random-record-generator", - "version": "0.1.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "airtable-extension-random-record-generator", - "version": "0.1.0", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "@airtable/blocks": "^1.18.1", @@ -27,6 +27,7 @@ "@typescript-eslint/parser": "^6.21.0", "babel-plugin-module-resolver": "^5.0.0", "eslint": "^8.56.0", + "eslint-plugin-jest": "^28.3.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^29.7.0", @@ -6015,6 +6016,31 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-plugin-jest": { + "version": "28.3.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.3.0.tgz", + "integrity": "sha512-5LjCSSno8E+IUCOX4hJiIb/upPIgpkaDEcaN/40gOcw26t/5UTLHFc4JdxKjOOvGTh0XdCu+fNr0fpOVNvcxMA==", + "dev": true, + "dependencies": { + "@typescript-eslint/utils": "^6.0.0" + }, + "engines": { + "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0", + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, "node_modules/eslint-plugin-react": { "version": "7.33.2", "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.33.2.tgz", diff --git a/package.json b/package.json index 2db9a12..83e5c43 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@typescript-eslint/parser": "^6.21.0", "babel-plugin-module-resolver": "^5.0.0", "eslint": "^8.56.0", + "eslint-plugin-jest": "^28.3.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "jest": "^29.7.0",