From 9ed14d649476d83455bc8ba2cbb0a768af390012 Mon Sep 17 00:00:00 2001 From: Riley Tomasek Date: Mon, 29 May 2023 19:15:51 -0400 Subject: [PATCH] Add prettier and reformat files --- .editorconfig | 9 ++ .prettierignore | 3 + .prettierrc | 3 + README.md | 6 +- index.js | 46 ++++---- internal.js | 64 +++++------ jest-testing-library.js | 14 +-- jest.js | 20 ++-- node.js | 4 +- package-lock.json | 17 ++- package.json | 6 +- rules/core.js | 148 ++++++++++++------------- rules/import.js | 6 +- rules/jest-dom.js | 22 ++-- rules/jest.js | 26 ++--- rules/jsx-a11y.js | 30 ++--- rules/packageExports.js | 230 +++++++++++++++++++-------------------- rules/react.js | 42 +++---- rules/testing-library.js | 38 +++---- rules/typescript.js | 36 +++--- settings/import.js | 14 +-- settings/react.js | 12 +- 22 files changed, 417 insertions(+), 379 deletions(-) create mode 100644 .editorconfig create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c6c8b36 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..177d788 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +node_modules +*.md +package*.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..544138b --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/README.md b/README.md index 44ef8a2..7d16d31 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -# `@remix-run/eslint-config` +# Forked from `@remix-run/eslint-config` + +Personal ESlint config forked from Remix to support non-remix environments. + +--- This package includes a shareable ESLint config for Remix projects. diff --git a/index.js b/index.js index 660bb16..72b1c36 100644 --- a/index.js +++ b/index.js @@ -1,18 +1,18 @@ // Splitting rules into separate modules allow for a lower-level API if our // default rules become difficult to extend without lots of duplication. -const coreRules = require("./rules/core"); -const importRules = require("./rules/import"); -const reactRules = require("./rules/react"); -const jsxA11yRules = require("./rules/jsx-a11y"); -const typescriptRules = require("./rules/typescript"); -const importSettings = require("./settings/import"); -const reactSettings = require("./settings/react"); +const coreRules = require('./rules/core'); +const importRules = require('./rules/import'); +const reactRules = require('./rules/react'); +const jsxA11yRules = require('./rules/jsx-a11y'); +const typescriptRules = require('./rules/typescript'); +const importSettings = require('./settings/import'); +const reactSettings = require('./settings/react'); /** * @see https://github.com/eslint/eslint/issues/3458 * @see https://www.npmjs.com/package/@rushstack/eslint-patch */ -require("@rushstack/eslint-patch/modern-module-resolution"); +require('@rushstack/eslint-patch/modern-module-resolution'); const OFF = 0; // const WARN = 1; @@ -20,13 +20,13 @@ const OFF = 0; /** @type {import('eslint').Linter.Config} */ const config = { - parser: "@babel/eslint-parser", + parser: '@babel/eslint-parser', parserOptions: { - sourceType: "module", + sourceType: 'module', requireConfigFile: false, - ecmaVersion: "latest", + ecmaVersion: 'latest', babelOptions: { - presets: [require.resolve("@babel/preset-react")], + presets: [require.resolve('@babel/preset-react')], }, }, env: { @@ -34,7 +34,7 @@ const config = { commonjs: true, es6: true, }, - plugins: ["import", "react", "react-hooks", "jsx-a11y"], + plugins: ['import', 'react', 'react-hooks', 'jsx-a11y'], settings: { ...reactSettings, ...importSettings, @@ -61,34 +61,34 @@ const config = { }, overrides: [ { - files: ["**/*.ts?(x)"], - extends: ["plugin:import/typescript"], - parser: "@typescript-eslint/parser", + files: ['**/*.ts?(x)'], + extends: ['plugin:import/typescript'], + parser: '@typescript-eslint/parser', parserOptions: { - sourceType: "module", + sourceType: 'module', ecmaVersion: 2019, ecmaFeatures: { jsx: true, }, warnOnUnsupportedTypeScriptVersion: true, }, - plugins: ["@typescript-eslint"], + plugins: ['@typescript-eslint'], rules: { ...typescriptRules, }, }, { files: [ - "**/routes/**/*.js?(x)", - "**/routes/**/*.tsx", - "app/root.js?(x)", - "app/root.tsx", + '**/routes/**/*.js?(x)', + '**/routes/**/*.tsx', + 'app/root.js?(x)', + 'app/root.tsx', ], rules: { // Routes may use default exports without a name. At the route level // identifying components for debugging purposes is less of an issue, as // the route boundary is more easily identifiable. - "react/display-name": OFF, + 'react/display-name': OFF, }, }, ], diff --git a/internal.js b/internal.js index aade8ad..6518997 100644 --- a/internal.js +++ b/internal.js @@ -7,7 +7,7 @@ * @see https://github.com/eslint/eslint/issues/3458 * @see https://www.npmjs.com/package/@rushstack/eslint-patch */ -require("@rushstack/eslint-patch/modern-module-resolution"); +require('@rushstack/eslint-patch/modern-module-resolution'); const OFF = 0; const WARN = 1; @@ -17,8 +17,8 @@ const ERROR = 2; module.exports = { root: true, extends: [ - require.resolve("./index.js"), - require.resolve("./jest-testing-library.js"), + require.resolve('./index.js'), + require.resolve('./jest-testing-library.js'), ], env: { node: true, @@ -27,62 +27,62 @@ module.exports = { // Plugins used in the internal config should be installed in our // repositories. We don't want to ship these as dependencies to consumers // who may not use them. - "node", - "prefer-let", + 'node', + 'prefer-let', ], rules: { - "@typescript-eslint/consistent-type-imports": ERROR, - "import/order": [ + '@typescript-eslint/consistent-type-imports': ERROR, + 'import/order': [ ERROR, { - "newlines-between": "always", + 'newlines-between': 'always', groups: [ - ["builtin", "external"], - "internal", - ["parent", "sibling", "index"], + ['builtin', 'external'], + 'internal', + ['parent', 'sibling', 'index'], ], }, ], - "jest/no-disabled-tests": OFF, - "prefer-let/prefer-let": WARN, + 'jest/no-disabled-tests': OFF, + 'prefer-let/prefer-let': WARN, }, overrides: [ { // all code blocks in .md files - files: ["**/*.md/*.js?(x)", "**/*.md/*.ts?(x)"], + files: ['**/*.md/*.js?(x)', '**/*.md/*.ts?(x)'], rules: { - "no-unreachable": OFF, - "no-unused-expressions": OFF, - "no-unused-labels": OFF, - "no-unused-vars": OFF, - "prefer-const": WARN, - "jsx-a11y/alt-text": OFF, - "jsx-a11y/anchor-has-content": OFF, - "prefer-let/prefer-let": OFF, - "react/jsx-no-comment-textnodes": OFF, - "react/jsx-no-undef": OFF, + 'no-unreachable': OFF, + 'no-unused-expressions': OFF, + 'no-unused-labels': OFF, + 'no-unused-vars': OFF, + 'prefer-const': WARN, + 'jsx-a11y/alt-text': OFF, + 'jsx-a11y/anchor-has-content': OFF, + 'prefer-let/prefer-let': OFF, + 'react/jsx-no-comment-textnodes': OFF, + 'react/jsx-no-undef': OFF, }, }, { // all ```ts & ```tsx code blocks in .md files - files: ["**/*.md/*.ts?(x)"], + files: ['**/*.md/*.ts?(x)'], rules: { - "@typescript-eslint/no-unused-expressions": OFF, - "@typescript-eslint/no-unused-vars": OFF, + '@typescript-eslint/no-unused-expressions': OFF, + '@typescript-eslint/no-unused-vars': OFF, }, }, { - files: ["packages/**/*.*"], - excludedFiles: "**/__tests__/**/*.*", + files: ['packages/**/*.*'], + excludedFiles: '**/__tests__/**/*.*', rules: { // Validate dependencies are listed in workspace package.json files - "import/no-extraneous-dependencies": ERROR, + 'import/no-extraneous-dependencies': ERROR, }, }, { - files: ["integration/**/*.*"], + files: ['integration/**/*.*'], env: { - "jest/globals": false, + 'jest/globals': false, }, }, ], diff --git a/jest-testing-library.js b/jest-testing-library.js index db2e297..5cc22f8 100644 --- a/jest-testing-library.js +++ b/jest-testing-library.js @@ -1,23 +1,23 @@ -const jestRules = require("./rules/jest"); -const jestDomRules = require("./rules/jest-dom"); -const testingLibraryRules = require("./rules/testing-library"); +const jestRules = require('./rules/jest'); +const jestDomRules = require('./rules/jest-dom'); +const testingLibraryRules = require('./rules/testing-library'); /** * @see https://github.com/eslint/eslint/issues/3458 * @see https://www.npmjs.com/package/@rushstack/eslint-patch */ -require("@rushstack/eslint-patch/modern-module-resolution"); +require('@rushstack/eslint-patch/modern-module-resolution'); module.exports = { - plugins: ["jest", "jest-dom", "testing-library"], + plugins: ['jest', 'jest-dom', 'testing-library'], env: { node: true, }, overrides: [ { - files: ["**/__tests__/**/*", "**/*.{spec,test}.*"], + files: ['**/__tests__/**/*', '**/*.{spec,test}.*'], env: { - "jest/globals": true, + 'jest/globals': true, }, rules: { ...jestRules, diff --git a/jest.js b/jest.js index dac2ee8..effe95e 100644 --- a/jest.js +++ b/jest.js @@ -1,10 +1,10 @@ -const jestRules = require("./rules/jest"); +const jestRules = require('./rules/jest'); /** * @see https://github.com/eslint/eslint/issues/3458 * @see https://www.npmjs.com/package/@rushstack/eslint-patch */ -require("@rushstack/eslint-patch/modern-module-resolution"); +require('@rushstack/eslint-patch/modern-module-resolution'); const alreadyWarned = {}; const warnOnce = (condition, message) => { @@ -16,26 +16,26 @@ const warnOnce = (condition, message) => { warnOnce( false, - "⚠️ DEPRECATED: The `@remix-run/eslint-config/jest` ESLint config " + - "has been deprecated in favor of " + - "`@remix-run/eslint-config/jest-testing-library` and will be removed in " + - "Remix v2. Please update your code to use " + - "`@remix-run/eslint-config/jest-testing-library` instead." + '⚠️ DEPRECATED: The `@remix-run/eslint-config/jest` ESLint config ' + + 'has been deprecated in favor of ' + + '`@remix-run/eslint-config/jest-testing-library` and will be removed in ' + + 'Remix v2. Please update your code to use ' + + '`@remix-run/eslint-config/jest-testing-library` instead.' ); /** * @deprecated Use `@remix-run/eslint-config/jest-testing-library` instead. */ const jestConfig = { - plugins: ["jest"], + plugins: ['jest'], env: { node: true, }, overrides: [ { - files: ["**/__tests__/**/*", "**/*.{spec,test}.*"], + files: ['**/__tests__/**/*', '**/*.{spec,test}.*'], env: { - "jest/globals": true, + 'jest/globals': true, }, rules: { ...jestRules, diff --git a/node.js b/node.js index e515800..f5949ed 100644 --- a/node.js +++ b/node.js @@ -2,10 +2,10 @@ * @see https://github.com/eslint/eslint/issues/3458 * @see https://www.npmjs.com/package/@rushstack/eslint-patch */ -require("@rushstack/eslint-patch/modern-module-resolution"); +require('@rushstack/eslint-patch/modern-module-resolution'); module.exports = { - plugins: ["node"], + plugins: ['node'], env: { node: true, }, diff --git a/package-lock.json b/package-lock.json index e5b625f..df9c09a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,8 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-testing-library": "^5.10.2" + "eslint-plugin-testing-library": "^5.10.2", + "prettier": "^2.8.8" }, "devDependencies": { "@types/eslint": "^8.37.0", @@ -7553,6 +7554,20 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", diff --git a/package.json b/package.json index 85c8831..4079413 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,9 @@ "rules", "settings" ], + "scripts": { + "format": "prettier --write ." + }, "dependencies": { "@babel/core": "^7.21.8", "@babel/eslint-parser": "^7.21.8", @@ -38,7 +41,8 @@ "eslint-plugin-node": "^11.1.0", "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", - "eslint-plugin-testing-library": "^5.10.2" + "eslint-plugin-testing-library": "^5.10.2", + "prettier": "^2.8.8" }, "devDependencies": { "@types/eslint": "^8.37.0", diff --git a/rules/core.js b/rules/core.js index aff9275..ac477df 100644 --- a/rules/core.js +++ b/rules/core.js @@ -7,7 +7,7 @@ const { cloudflareWorkersSpecificExports, nodeSpecificExports, reactSpecificExports, -} = require("./packageExports"); +} = require('./packageExports'); // const OFF = 0; const WARN = 1; @@ -20,87 +20,87 @@ const replaceRemixImportsOptions = [ { packageExports: defaultAdapterExports, packageName: - "{architect|cloudflare-pages|cloudflare-workers|express|netlify|vercel}", + '{architect|cloudflare-pages|cloudflare-workers|express|netlify|vercel}', }, - { packageExports: defaultRuntimeExports, packageName: "{cloudflare|node}" }, - { packageExports: architectSpecificExports, packageName: "architect" }, - { packageExports: cloudflareSpecificExports, packageName: "cloudflare" }, + { packageExports: defaultRuntimeExports, packageName: '{cloudflare|node}' }, + { packageExports: architectSpecificExports, packageName: 'architect' }, + { packageExports: cloudflareSpecificExports, packageName: 'cloudflare' }, { packageExports: cloudflarePagesSpecificExports, - packageName: "cloudflare-pages", + packageName: 'cloudflare-pages', }, { packageExports: cloudflareWorkersSpecificExports, - packageName: "cloudflare-workers", + packageName: 'cloudflare-workers', }, - { packageExports: nodeSpecificExports, packageName: "node" }, - { packageExports: reactSpecificExports, packageName: "react" }, + { packageExports: nodeSpecificExports, packageName: 'node' }, + { packageExports: reactSpecificExports, packageName: 'react' }, ].map(({ packageExports, packageName }) => ({ importNames: [...packageExports.value, ...packageExports.type], message: getReplaceRemixImportsMessage(packageName), - name: "remix", + name: 'remix', })); module.exports = { - "array-callback-return": WARN, - "getter-return": WARN, - "new-parens": WARN, - "no-array-constructor": WARN, - "no-caller": ERROR, - "no-cond-assign": [WARN, "except-parens"], - "no-const-assign": ERROR, - "no-control-regex": WARN, - "no-dupe-args": WARN, - "no-dupe-class-members": WARN, - "no-dupe-keys": WARN, - "no-duplicate-case": WARN, - "no-empty-character-class": WARN, - "no-empty-pattern": WARN, - "no-duplicate-imports": WARN, - "no-empty": [WARN, { allowEmptyCatch: true }], - "no-eval": ERROR, - "no-ex-assign": WARN, - "no-extend-native": WARN, - "no-extra-bind": WARN, - "no-extra-label": WARN, - "no-extra-boolean-cast": WARN, - "no-func-assign": ERROR, - "no-global-assign": ERROR, - "no-implied-eval": WARN, - "no-invalid-regexp": WARN, - "no-label-var": WARN, - "no-labels": [WARN, { allowLoop: true, allowSwitch: false }], - "no-lone-blocks": WARN, - "no-loop-func": WARN, - "no-mixed-operators": [ + 'array-callback-return': WARN, + 'getter-return': WARN, + 'new-parens': WARN, + 'no-array-constructor': WARN, + 'no-caller': ERROR, + 'no-cond-assign': [WARN, 'except-parens'], + 'no-const-assign': ERROR, + 'no-control-regex': WARN, + 'no-dupe-args': WARN, + 'no-dupe-class-members': WARN, + 'no-dupe-keys': WARN, + 'no-duplicate-case': WARN, + 'no-empty-character-class': WARN, + 'no-empty-pattern': WARN, + 'no-duplicate-imports': WARN, + 'no-empty': [WARN, { allowEmptyCatch: true }], + 'no-eval': ERROR, + 'no-ex-assign': WARN, + 'no-extend-native': WARN, + 'no-extra-bind': WARN, + 'no-extra-label': WARN, + 'no-extra-boolean-cast': WARN, + 'no-func-assign': ERROR, + 'no-global-assign': ERROR, + 'no-implied-eval': WARN, + 'no-invalid-regexp': WARN, + 'no-label-var': WARN, + 'no-labels': [WARN, { allowLoop: true, allowSwitch: false }], + 'no-lone-blocks': WARN, + 'no-loop-func': WARN, + 'no-mixed-operators': [ WARN, { groups: [ - ["&", "|", "^", "~", "<<", ">>", ">>>"], - ["==", "!=", "===", "!==", ">", ">=", "<", "<="], - ["&&", "||"], - ["in", "instanceof"], + ['&', '|', '^', '~', '<<', '>>', '>>>'], + ['==', '!=', '===', '!==', '>', '>=', '<', '<='], + ['&&', '||'], + ['in', 'instanceof'], ], allowSamePrecedence: false, }, ], - "no-unsafe-negation": WARN, - "no-new-func": WARN, - "no-new-object": WARN, - "no-octal": WARN, - "no-redeclare": ERROR, - "no-restricted-imports": [WARN, ...replaceRemixImportsOptions], - "no-script-url": WARN, - "no-self-assign": WARN, - "no-self-compare": WARN, - "no-sequences": WARN, - "no-shadow-restricted-names": WARN, - "no-sparse-arrays": WARN, - "no-template-curly-in-string": WARN, - "no-this-before-super": WARN, - "no-undef": ERROR, - "no-unreachable": WARN, - "no-unused-expressions": [ + 'no-unsafe-negation': WARN, + 'no-new-func': WARN, + 'no-new-object': WARN, + 'no-octal': WARN, + 'no-redeclare': ERROR, + 'no-restricted-imports': [WARN, ...replaceRemixImportsOptions], + 'no-script-url': WARN, + 'no-self-assign': WARN, + 'no-self-compare': WARN, + 'no-sequences': WARN, + 'no-shadow-restricted-names': WARN, + 'no-sparse-arrays': WARN, + 'no-template-curly-in-string': WARN, + 'no-this-before-super': WARN, + 'no-undef': ERROR, + 'no-unreachable': WARN, + 'no-unused-expressions': [ WARN, { allowShortCircuit: true, @@ -108,23 +108,23 @@ module.exports = { allowTaggedTemplates: true, }, ], - "no-unused-labels": WARN, - "no-unused-vars": [ + 'no-unused-labels': WARN, + 'no-unused-vars': [ WARN, { - args: "none", + args: 'none', ignoreRestSiblings: true, }, ], - "no-use-before-define": [ + 'no-use-before-define': [ WARN, { classes: false, functions: false, variables: false }, ], - "no-useless-computed-key": WARN, - "no-useless-concat": WARN, - "no-useless-constructor": WARN, - "no-useless-escape": WARN, - "no-useless-rename": [ + 'no-useless-computed-key': WARN, + 'no-useless-concat': WARN, + 'no-useless-constructor': WARN, + 'no-useless-escape': WARN, + 'no-useless-rename': [ WARN, { ignoreDestructuring: false, @@ -132,7 +132,7 @@ module.exports = { ignoreExport: false, }, ], - "require-yield": WARN, - "use-isnan": WARN, - "valid-typeof": WARN, + 'require-yield': WARN, + 'use-isnan': WARN, + 'valid-typeof': WARN, }; diff --git a/rules/import.js b/rules/import.js index b98e759..05f8483 100644 --- a/rules/import.js +++ b/rules/import.js @@ -3,7 +3,7 @@ const ERROR = 2; module.exports = { - "import/first": ERROR, - "import/no-amd": ERROR, - "import/no-webpack-loader-syntax": ERROR, + 'import/first': ERROR, + 'import/no-amd': ERROR, + 'import/no-webpack-loader-syntax': ERROR, }; diff --git a/rules/jest-dom.js b/rules/jest-dom.js index aad70a2..3ba7676 100644 --- a/rules/jest-dom.js +++ b/rules/jest-dom.js @@ -3,15 +3,15 @@ const WARN = 1; // const ERROR = 2; module.exports = { - "jest-dom/prefer-checked": WARN, - "jest-dom/prefer-empty": WARN, - "jest-dom/prefer-enabled-disabled": WARN, - "jest-dom/prefer-focus": WARN, - "jest-dom/prefer-in-document": WARN, - "jest-dom/prefer-required": WARN, - "jest-dom/prefer-to-have-attribute": WARN, - "jest-dom/prefer-to-have-class": WARN, - "jest-dom/prefer-to-have-style": WARN, - "jest-dom/prefer-to-have-text-content": WARN, - "jest-dom/prefer-to-have-value": WARN, + 'jest-dom/prefer-checked': WARN, + 'jest-dom/prefer-empty': WARN, + 'jest-dom/prefer-enabled-disabled': WARN, + 'jest-dom/prefer-focus': WARN, + 'jest-dom/prefer-in-document': WARN, + 'jest-dom/prefer-required': WARN, + 'jest-dom/prefer-to-have-attribute': WARN, + 'jest-dom/prefer-to-have-class': WARN, + 'jest-dom/prefer-to-have-style': WARN, + 'jest-dom/prefer-to-have-text-content': WARN, + 'jest-dom/prefer-to-have-value': WARN, }; diff --git a/rules/jest.js b/rules/jest.js index 89f235d..4ad4961 100644 --- a/rules/jest.js +++ b/rules/jest.js @@ -3,17 +3,17 @@ const WARN = 1; const ERROR = 2; module.exports = { - "jest/no-conditional-expect": WARN, - "jest/no-deprecated-functions": WARN, - "jest/no-disabled-tests": WARN, - "jest/no-export": ERROR, - "jest/no-focused-tests": WARN, - "jest/no-identical-title": WARN, - "jest/no-interpolation-in-snapshots": WARN, - "jest/no-jasmine-globals": ERROR, - "jest/no-jest-import": WARN, - "jest/no-mocks-import": WARN, - "jest/valid-describe-callback": ERROR, - "jest/valid-expect": ERROR, - "jest/valid-expect-in-promise": ERROR, + 'jest/no-conditional-expect': WARN, + 'jest/no-deprecated-functions': WARN, + 'jest/no-disabled-tests': WARN, + 'jest/no-export': ERROR, + 'jest/no-focused-tests': WARN, + 'jest/no-identical-title': WARN, + 'jest/no-interpolation-in-snapshots': WARN, + 'jest/no-jasmine-globals': ERROR, + 'jest/no-jest-import': WARN, + 'jest/no-mocks-import': WARN, + 'jest/valid-describe-callback': ERROR, + 'jest/valid-expect': ERROR, + 'jest/valid-expect-in-promise': ERROR, }; diff --git a/rules/jsx-a11y.js b/rules/jsx-a11y.js index 3f19447..1752de0 100644 --- a/rules/jsx-a11y.js +++ b/rules/jsx-a11y.js @@ -3,19 +3,19 @@ const WARN = 1; // const ERROR = 2; module.exports = { - "jsx-a11y/alt-text": WARN, - "jsx-a11y/anchor-has-content": [WARN, { components: ["Link", "NavLink"] }], - "jsx-a11y/anchor-is-valid": [WARN, { aspects: ["noHref", "invalidHref"] }], - "jsx-a11y/aria-activedescendant-has-tabindex": WARN, - "jsx-a11y/aria-props": WARN, - "jsx-a11y/aria-proptypes": WARN, - "jsx-a11y/aria-role": [WARN, { ignoreNonDOM: true }], - "jsx-a11y/aria-unsupported-elements": WARN, - "jsx-a11y/iframe-has-title": WARN, - "jsx-a11y/img-redundant-alt": WARN, - "jsx-a11y/lang": WARN, - "jsx-a11y/no-access-key": WARN, - "jsx-a11y/no-redundant-roles": WARN, - "jsx-a11y/role-has-required-aria-props": WARN, - "jsx-a11y/role-supports-aria-props": WARN, + 'jsx-a11y/alt-text': WARN, + 'jsx-a11y/anchor-has-content': [WARN, { components: ['Link', 'NavLink'] }], + 'jsx-a11y/anchor-is-valid': [WARN, { aspects: ['noHref', 'invalidHref'] }], + 'jsx-a11y/aria-activedescendant-has-tabindex': WARN, + 'jsx-a11y/aria-props': WARN, + 'jsx-a11y/aria-proptypes': WARN, + 'jsx-a11y/aria-role': [WARN, { ignoreNonDOM: true }], + 'jsx-a11y/aria-unsupported-elements': WARN, + 'jsx-a11y/iframe-has-title': WARN, + 'jsx-a11y/img-redundant-alt': WARN, + 'jsx-a11y/lang': WARN, + 'jsx-a11y/no-access-key': WARN, + 'jsx-a11y/no-redundant-roles': WARN, + 'jsx-a11y/role-has-required-aria-props': WARN, + 'jsx-a11y/role-supports-aria-props': WARN, }; diff --git a/rules/packageExports.js b/rules/packageExports.js index a3c02ef..1a42f9c 100644 --- a/rules/packageExports.js +++ b/rules/packageExports.js @@ -1,152 +1,152 @@ const defaultAdapterExports = { - value: ["createRequestHandler"], - type: ["GetLoadContextFunction", "RequestHandler"], + value: ['createRequestHandler'], + type: ['GetLoadContextFunction', 'RequestHandler'], }; const defaultRuntimeExports = { value: [ - "createCookie", - "createCookieSessionStorage", - "createMemorySessionStorage", - "createRequestHandler", - "createSession", - "createSessionStorage", - "isCookie", - "isSession", - "json", - "MaxPartSizeExceededError", - "redirect", - "unstable_composeUploadHandlers", - "unstable_createMemoryUploadHandler", - "unstable_parseMultipartFormData", + 'createCookie', + 'createCookieSessionStorage', + 'createMemorySessionStorage', + 'createRequestHandler', + 'createSession', + 'createSessionStorage', + 'isCookie', + 'isSession', + 'json', + 'MaxPartSizeExceededError', + 'redirect', + 'unstable_composeUploadHandlers', + 'unstable_createMemoryUploadHandler', + 'unstable_parseMultipartFormData', ], type: [ - "ActionFunction", - "AppData", - "AppLoadContext", - "Cookie", - "CookieOptions", - "CookieParseOptions", - "CookieSerializeOptions", - "CookieSignatureOptions", - "CreateRequestHandlerFunction", - "DataFunctionArgs", - "EntryContext", - "ErrorBoundaryComponent", - "HandleDataRequestFunction", - "HandleDocumentRequestFunction", - "HeadersFunction", - "HtmlLinkDescriptor", - "HtmlMetaDescriptor", - "LinkDescriptor", - "LinksFunction", - "LoaderFunction", - "MemoryUploadHandlerFilterArgs", - "MemoryUploadHandlerOptions", - "MetaDescriptor", - "MetaFunction", - "PageLinkDescriptor", - "RequestHandler", - "RouteComponent", - "RouteHandle", - "ServerBuild", - "ServerEntryModule", - "Session", - "SessionData", - "SessionIdStorageStrategy", - "SessionStorage", - "UploadHandler", - "UploadHandlerPart", + 'ActionFunction', + 'AppData', + 'AppLoadContext', + 'Cookie', + 'CookieOptions', + 'CookieParseOptions', + 'CookieSerializeOptions', + 'CookieSignatureOptions', + 'CreateRequestHandlerFunction', + 'DataFunctionArgs', + 'EntryContext', + 'ErrorBoundaryComponent', + 'HandleDataRequestFunction', + 'HandleDocumentRequestFunction', + 'HeadersFunction', + 'HtmlLinkDescriptor', + 'HtmlMetaDescriptor', + 'LinkDescriptor', + 'LinksFunction', + 'LoaderFunction', + 'MemoryUploadHandlerFilterArgs', + 'MemoryUploadHandlerOptions', + 'MetaDescriptor', + 'MetaFunction', + 'PageLinkDescriptor', + 'RequestHandler', + 'RouteComponent', + 'RouteHandle', + 'ServerBuild', + 'ServerEntryModule', + 'Session', + 'SessionData', + 'SessionIdStorageStrategy', + 'SessionStorage', + 'UploadHandler', + 'UploadHandlerPart', ], }; const architectSpecificExports = { - value: ["createArcTableSessionStorage"], + value: ['createArcTableSessionStorage'], type: [], }; const cloudflareSpecificExports = { - value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"], + value: ['createCloudflareKVSessionStorage', 'createWorkersKVSessionStorage'], type: [], }; const cloudflarePagesSpecificExports = { - value: ["createPagesFunctionHandler"], - type: ["createPagesFunctionHandlerParams"], + value: ['createPagesFunctionHandler'], + type: ['createPagesFunctionHandlerParams'], }; const cloudflareWorkersSpecificExports = { - value: ["createEventHandler", "handleAsset"], + value: ['createEventHandler', 'handleAsset'], type: [], }; const nodeSpecificExports = { value: [ - "AbortController", - "createFileSessionStorage", - "createReadableStreamFromReadable", - "fetch", - "FormData", - "Headers", - "installGlobals", - "NodeOnDiskFile", - "readableStreamToString", - "Request", - "Response", - "unstable_createFileUploadHandler", - "writeAsyncIterableToWritable", - "writeReadableStreamToWritable", + 'AbortController', + 'createFileSessionStorage', + 'createReadableStreamFromReadable', + 'fetch', + 'FormData', + 'Headers', + 'installGlobals', + 'NodeOnDiskFile', + 'readableStreamToString', + 'Request', + 'Response', + 'unstable_createFileUploadHandler', + 'writeAsyncIterableToWritable', + 'writeReadableStreamToWritable', ], - type: ["HeadersInit", "RequestInfo", "RequestInit", "ResponseInit"], + type: ['HeadersInit', 'RequestInfo', 'RequestInit', 'ResponseInit'], }; const reactSpecificExports = { value: [ - "Form", - "Link", - "Links", - "LiveReload", - "Meta", - "NavLink", - "Outlet", - "PrefetchPageLinks", - "RemixBrowser", - "RemixServer", - "Scripts", - "ScrollRestoration", - "useActionData", - "useBeforeUnload", - "useCatch", - "useFetcher", - "useFetchers", - "useFormAction", - "useHref", - "useLoaderData", - "useLocation", - "useMatches", - "useNavigate", - "useNavigationType", - "useOutlet", - "useOutletContext", - "useParams", - "useResolvedPath", - "useSearchParams", - "useSubmit", - "useTransition", + 'Form', + 'Link', + 'Links', + 'LiveReload', + 'Meta', + 'NavLink', + 'Outlet', + 'PrefetchPageLinks', + 'RemixBrowser', + 'RemixServer', + 'Scripts', + 'ScrollRestoration', + 'useActionData', + 'useBeforeUnload', + 'useCatch', + 'useFetcher', + 'useFetchers', + 'useFormAction', + 'useHref', + 'useLoaderData', + 'useLocation', + 'useMatches', + 'useNavigate', + 'useNavigationType', + 'useOutlet', + 'useOutletContext', + 'useParams', + 'useResolvedPath', + 'useSearchParams', + 'useSubmit', + 'useTransition', ], type: [ - "FormEncType", - "FormMethod", - "FormProps", - "HtmlLinkDescriptor", - "HtmlMetaDescriptor", - "LinkProps", - "NavLinkProps", - "RemixBrowserProps", - "RemixServerProps", - "SubmitFunction", - "SubmitOptions", - "ThrownResponse", + 'FormEncType', + 'FormMethod', + 'FormProps', + 'HtmlLinkDescriptor', + 'HtmlMetaDescriptor', + 'LinkProps', + 'NavLinkProps', + 'RemixBrowserProps', + 'RemixServerProps', + 'SubmitFunction', + 'SubmitOptions', + 'ThrownResponse', ], }; diff --git a/rules/react.js b/rules/react.js index 98b1392..c44b3a6 100644 --- a/rules/react.js +++ b/rules/react.js @@ -3,28 +3,28 @@ const WARN = 1; const ERROR = 2; module.exports = { - "react/display-name": WARN, - "react/forbid-foreign-prop-types": [WARN, { allowInPropTypes: true }], - "react/jsx-key": WARN, - "react/jsx-no-comment-textnodes": WARN, - "react/jsx-no-target-blank": WARN, - "react/jsx-no-undef": ERROR, - "react/jsx-pascal-case": [WARN, { allowAllCaps: true, ignore: [] }], - "react/jsx-uses-vars": WARN, - "react/jsx-uses-react": WARN, - "react/no-danger-with-children": WARN, - "react/no-direct-mutation-state": WARN, - "react/no-find-dom-node": WARN, - "react/no-is-mounted": WARN, - "react/no-render-return-value": ERROR, - "react/no-string-refs": WARN, - "react/no-typos": WARN, - "react/react-in-jsx-scope": OFF, - "react/require-render-return": ERROR, - "react/style-prop-object": WARN, + 'react/display-name': WARN, + 'react/forbid-foreign-prop-types': [WARN, { allowInPropTypes: true }], + 'react/jsx-key': WARN, + 'react/jsx-no-comment-textnodes': WARN, + 'react/jsx-no-target-blank': WARN, + 'react/jsx-no-undef': ERROR, + 'react/jsx-pascal-case': [WARN, { allowAllCaps: true, ignore: [] }], + 'react/jsx-uses-vars': WARN, + 'react/jsx-uses-react': WARN, + 'react/no-danger-with-children': WARN, + 'react/no-direct-mutation-state': WARN, + 'react/no-find-dom-node': WARN, + 'react/no-is-mounted': WARN, + 'react/no-render-return-value': ERROR, + 'react/no-string-refs': WARN, + 'react/no-typos': WARN, + 'react/react-in-jsx-scope': OFF, + 'react/require-render-return': ERROR, + 'react/style-prop-object': WARN, // react-hooks // https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks - "react-hooks/exhaustive-deps": WARN, - "react-hooks/rules-of-hooks": ERROR, + 'react-hooks/exhaustive-deps': WARN, + 'react-hooks/rules-of-hooks': ERROR, }; diff --git a/rules/testing-library.js b/rules/testing-library.js index 96b3408..17b8478 100644 --- a/rules/testing-library.js +++ b/rules/testing-library.js @@ -3,23 +3,23 @@ const WARN = 1; const ERROR = 2; module.exports = { - "testing-library/await-async-query": ERROR, - "testing-library/await-async-utils": ERROR, - "testing-library/no-await-sync-events": ERROR, - "testing-library/no-await-sync-query": ERROR, - "testing-library/no-debugging-utils": WARN, - "testing-library/no-promise-in-fire-event": ERROR, - "testing-library/no-render-in-setup": ERROR, - "testing-library/no-unnecessary-act": ERROR, - "testing-library/no-wait-for-empty-callback": ERROR, - "testing-library/no-wait-for-multiple-assertions": ERROR, - "testing-library/no-wait-for-side-effects": ERROR, - "testing-library/no-wait-for-snapshot": ERROR, - "testing-library/prefer-find-by": WARN, - "testing-library/prefer-presence-queries": WARN, - "testing-library/prefer-query-by-disappearance": WARN, - "testing-library/prefer-screen-queries": WARN, - "testing-library/prefer-user-event": WARN, - "testing-library/prefer-wait-for": WARN, - "testing-library/render-result-naming-convention": WARN, + 'testing-library/await-async-query': ERROR, + 'testing-library/await-async-utils': ERROR, + 'testing-library/no-await-sync-events': ERROR, + 'testing-library/no-await-sync-query': ERROR, + 'testing-library/no-debugging-utils': WARN, + 'testing-library/no-promise-in-fire-event': ERROR, + 'testing-library/no-render-in-setup': ERROR, + 'testing-library/no-unnecessary-act': ERROR, + 'testing-library/no-wait-for-empty-callback': ERROR, + 'testing-library/no-wait-for-multiple-assertions': ERROR, + 'testing-library/no-wait-for-side-effects': ERROR, + 'testing-library/no-wait-for-snapshot': ERROR, + 'testing-library/prefer-find-by': WARN, + 'testing-library/prefer-presence-queries': WARN, + 'testing-library/prefer-query-by-disappearance': WARN, + 'testing-library/prefer-screen-queries': WARN, + 'testing-library/prefer-user-event': WARN, + 'testing-library/prefer-wait-for': WARN, + 'testing-library/render-result-naming-convention': WARN, }; diff --git a/rules/typescript.js b/rules/typescript.js index f81d2f1..ce443e4 100644 --- a/rules/typescript.js +++ b/rules/typescript.js @@ -3,27 +3,27 @@ const WARN = 1; const ERROR = 2; module.exports = { - "no-dupe-class-members": OFF, - "no-undef": OFF, + 'no-dupe-class-members': OFF, + 'no-undef': OFF, // Add TypeScript specific rules (and turn off ESLint equivalents) - "@typescript-eslint/consistent-type-assertions": WARN, - "@typescript-eslint/consistent-type-imports": WARN, + '@typescript-eslint/consistent-type-assertions': WARN, + '@typescript-eslint/consistent-type-imports': WARN, - "no-array-constructor": OFF, - "@typescript-eslint/no-array-constructor": WARN, + 'no-array-constructor': OFF, + '@typescript-eslint/no-array-constructor': WARN, // There is a bug w/ @typescript-eslint/no-duplicate-imports triggered // by multiple imports inside of module declarations. We should reenable // this rule when the bug is fixed. // https://github.com/typescript-eslint/typescript-eslint/issues/3071 - "no-duplicate-imports": OFF, + 'no-duplicate-imports': OFF, // "@typescript-eslint/no-duplicate-imports": WARN, - "no-redeclare": OFF, - "@typescript-eslint/no-redeclare": ERROR, - "no-use-before-define": OFF, - "@typescript-eslint/no-use-before-define": [ + 'no-redeclare': OFF, + '@typescript-eslint/no-redeclare': ERROR, + 'no-use-before-define': OFF, + '@typescript-eslint/no-use-before-define': [ WARN, { functions: false, @@ -32,8 +32,8 @@ module.exports = { typedefs: false, }, ], - "no-unused-expressions": OFF, - "@typescript-eslint/no-unused-expressions": [ + 'no-unused-expressions': OFF, + '@typescript-eslint/no-unused-expressions': [ WARN, { allowShortCircuit: true, @@ -41,14 +41,14 @@ module.exports = { allowTaggedTemplates: true, }, ], - "no-unused-vars": OFF, - "@typescript-eslint/no-unused-vars": [ + 'no-unused-vars': OFF, + '@typescript-eslint/no-unused-vars': [ WARN, { - args: "none", + args: 'none', ignoreRestSiblings: true, }, ], - "no-useless-constructor": OFF, - "@typescript-eslint/no-useless-constructor": WARN, + 'no-useless-constructor': OFF, + '@typescript-eslint/no-useless-constructor': WARN, }; diff --git a/settings/import.js b/settings/import.js index 63309b3..fcb919f 100644 --- a/settings/import.js +++ b/settings/import.js @@ -1,13 +1,13 @@ module.exports = { - "import/ignore": ["node_modules", "\\.(css|md|svg|json)$"], - "import/parsers": { - [require.resolve("@typescript-eslint/parser")]: [".ts", ".tsx", ".d.ts"], + 'import/ignore': ['node_modules', '\\.(css|md|svg|json)$'], + 'import/parsers': { + [require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'], }, - "import/resolver": { - [require.resolve("eslint-import-resolver-node")]: { - extensions: [".js", ".jsx", ".ts", ".tsx"], + 'import/resolver': { + [require.resolve('eslint-import-resolver-node')]: { + extensions: ['.js', '.jsx', '.ts', '.tsx'], }, - [require.resolve("eslint-import-resolver-typescript")]: { + [require.resolve('eslint-import-resolver-typescript')]: { alwaysTryTypes: true, }, }, diff --git a/settings/react.js b/settings/react.js index 1d91102..c0027a6 100644 --- a/settings/react.js +++ b/settings/react.js @@ -1,15 +1,15 @@ module.exports = { react: { - version: "detect", - formComponents: ["Form"], + version: 'detect', + formComponents: ['Form'], linkComponents: [ { - name: "Link", - linkAttribute: "to", + name: 'Link', + linkAttribute: 'to', }, { - name: "NavLink", - linkAttribute: "to", + name: 'NavLink', + linkAttribute: 'to', }, ], },