-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ESLint Love with Prettier and recommended
- Loading branch information
Showing
48 changed files
with
1,621 additions
and
898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
semi: false, | ||
singleQuote: true, | ||
jsxSingleQuote: true, | ||
arrowParens: 'avoid', | ||
printWidth: 100, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"arcanis.vscode-zipfs", | ||
"dbaeumer.vscode-eslint" | ||
"dbaeumer.vscode-eslint", | ||
"esbenp.prettier-vscode" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
const {existsSync} = require(`fs`); | ||
const {createRequire, register} = require(`module`); | ||
const {resolve} = require(`path`); | ||
const {pathToFileURL} = require(`url`); | ||
|
||
const relPnpApiPath = "../../../../.pnp.cjs"; | ||
|
||
const absPnpApiPath = resolve(__dirname, relPnpApiPath); | ||
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); | ||
const absRequire = createRequire(absPnpApiPath); | ||
|
||
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); | ||
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); | ||
|
||
if (existsSync(absPnpApiPath)) { | ||
if (!process.versions.pnp) { | ||
// Setup the environment to be able to require prettier/bin/prettier.cjs | ||
require(absPnpApiPath).setup(); | ||
if (isPnpLoaderEnabled && register) { | ||
register(pathToFileURL(absPnpLoaderPath)); | ||
} | ||
} | ||
} | ||
|
||
const wrapWithUserWrapper = existsSync(absUserWrapperPath) | ||
? exports => absRequire(absUserWrapperPath)(exports) | ||
: exports => exports; | ||
|
||
// Defer to the real prettier/bin/prettier.cjs your application uses | ||
module.exports = wrapWithUserWrapper(absRequire(`prettier/bin/prettier.cjs`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
const {existsSync} = require(`fs`); | ||
const {createRequire, register} = require(`module`); | ||
const {resolve} = require(`path`); | ||
const {pathToFileURL} = require(`url`); | ||
|
||
const relPnpApiPath = "../../../.pnp.cjs"; | ||
|
||
const absPnpApiPath = resolve(__dirname, relPnpApiPath); | ||
const absUserWrapperPath = resolve(__dirname, `./sdk.user.cjs`); | ||
const absRequire = createRequire(absPnpApiPath); | ||
|
||
const absPnpLoaderPath = resolve(absPnpApiPath, `../.pnp.loader.mjs`); | ||
const isPnpLoaderEnabled = existsSync(absPnpLoaderPath); | ||
|
||
if (existsSync(absPnpApiPath)) { | ||
if (!process.versions.pnp) { | ||
// Setup the environment to be able to require prettier | ||
require(absPnpApiPath).setup(); | ||
if (isPnpLoaderEnabled && register) { | ||
register(pathToFileURL(absPnpLoaderPath)); | ||
} | ||
} | ||
} | ||
|
||
const wrapWithUserWrapper = existsSync(absUserWrapperPath) | ||
? exports => absRequire(absUserWrapperPath)(exports) | ||
: exports => exports; | ||
|
||
// Defer to the real prettier your application uses | ||
module.exports = wrapWithUserWrapper(absRequire(`prettier`)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "prettier", | ||
"version": "3.4.2-sdk", | ||
"main": "./index.cjs", | ||
"type": "commonjs", | ||
"bin": "./bin/prettier.cjs" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,81 @@ | ||
import love from 'eslint-config-love' | ||
import js from '@eslint/js' | ||
import tseslint from 'typescript-eslint' | ||
import nextPlugin from '@next/eslint-plugin-next' | ||
import standardJsx from 'eslint-config-standard-jsx' | ||
import standardReact from 'eslint-config-standard-react' | ||
import react from 'eslint-plugin-react' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import importPlugin from 'eslint-plugin-import' | ||
import pluginPromise from 'eslint-plugin-promise' | ||
import nodePlugin from 'eslint-plugin-n' | ||
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' | ||
|
||
export default [ | ||
export default tseslint.config( | ||
{ | ||
ignores: ['.pnp.cjs', '.pnp.loader.mjs', '.yarn', '.next'], | ||
ignores: [ | ||
'.pnp.cjs', | ||
'.pnp.loader.mjs', | ||
'.yarn', | ||
'.next', | ||
'.prettierrc.mjs', | ||
'*.config.{mjs,js}', | ||
], | ||
}, | ||
js.configs.recommended, | ||
tseslint.configs.strictTypeChecked, | ||
tseslint.configs.stylisticTypeChecked, | ||
react.configs.flat.recommended, | ||
pluginPromise.configs['flat/recommended'], | ||
importPlugin.flatConfigs.recommended, // Could use TypeScript resolver | ||
nodePlugin.configs['flat/recommended-module'], | ||
{ | ||
...love, | ||
files: [ | ||
'__tests__/**/*.{js,ts,tsx}', | ||
'imports/**/*.{js,ts,tsx}', | ||
'pages/**/*.{js,ts,tsx}', | ||
], | ||
plugins: { '@next/next': nextPlugin }, | ||
rules: nextPlugin.configs.recommended.rules, | ||
}, | ||
{ | ||
plugins: { 'react-hooks': reactHooks }, | ||
rules: reactHooks.configs.recommended.rules, | ||
}, | ||
{ ...react.configs.flat.recommended, settings: { react: { version: 'detect' } } }, | ||
{ plugins: { 'react-hooks': reactHooks }, rules: reactHooks.configs.recommended.rules }, | ||
{ rules: standardJsx.rules }, | ||
{ rules: standardReact.rules }, | ||
{ | ||
settings: { react: { version: 'detect' } }, | ||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
rules: { | ||
// Make TypeScript ESLint less strict. | ||
'@typescript-eslint/strict-boolean-expressions': 'off', | ||
'@typescript-eslint/triple-slash-reference': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/no-confusing-void-expression': 'off', | ||
'multiline-ternary': 'off', // Temporary. | ||
// Allow no-multi-str. | ||
'no-multi-str': 'off', | ||
// Make ESLint Config Love less strict. Perhaps move to ESLint+TS-ESLint+import+promise+n? | ||
'@typescript-eslint/max-params': 'off', | ||
'@typescript-eslint/no-require-imports': 'off', | ||
/* '@typescript-eslint/restrict-template-expressions': [ | ||
'error', | ||
{ | ||
allowAny: false, | ||
allowBoolean: false, | ||
allowNullish: false, | ||
allowNumber: true, | ||
allowRegExp: false, | ||
allowNever: false, | ||
}, | ||
], */ | ||
'n/no-missing-import': 'off', | ||
'n/no-unsupported-features/node-builtins': 'off', | ||
'n/no-unsupported-features/es-syntax': 'off', | ||
'import/no-unresolved': 'off', | ||
// TODO: Re-enable these! | ||
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', | ||
'@typescript-eslint/restrict-template-expressions': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-return': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-magic-numbers': 'off', | ||
'@typescript-eslint/no-unsafe-argument': 'off', | ||
'@typescript-eslint/no-unsafe-assignment': 'off', | ||
'@typescript-eslint/no-unsafe-member-access': 'off', | ||
'@typescript-eslint/no-unnecessary-condition': 'off', | ||
'@typescript-eslint/no-unsafe-type-assertion': 'off', | ||
'@typescript-eslint/class-methods-use-this': 'off', | ||
'@typescript-eslint/prefer-destructuring': 'off', | ||
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off', | ||
'complexity': 'off', | ||
'promise/avoid-new': 'off', | ||
'@typescript-eslint/init-declarations': 'off', | ||
'@typescript-eslint/no-loop-func': 'off', | ||
'promise/catch-or-return': 'off', | ||
'promise/always-return': 'off', | ||
'promise/no-nesting': 'off', | ||
}, | ||
}, | ||
] | ||
eslintPluginPrettierRecommended, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.