Skip to content

Commit

Permalink
fix(lint): update prettier settings
Browse files Browse the repository at this point in the history
  • Loading branch information
JMaio committed Dec 25, 2020
1 parent 3944581 commit 2d7a9b4
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 65 deletions.
89 changes: 42 additions & 47 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,47 @@
// -----------
// https://www.robertcooper.me/using-eslint-and-prettier-in-a-typescript-project
{
"env": {
"browser": true,
// "es2021": true,
"jasmine": true,
"jest": true,
"es6": true
"env": {
"browser": true,
// "es2021": true,
"jasmine": true,
"jest": true,
"es6": true
},
"extends": [
"react-app", // Uses the recommended rules Create React App
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from @typescript-eslint/eslint-plugin
"prettier/react",
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
"prettier",
"plugin:prettier/recommended" // Should be last in the list. Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true // Allows for the parsing of JSX
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"react-app", // Uses the recommended rules Create React App
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
// "plugin:@typescript-eslint/recommended", // Uses the recommended rules from @typescript-eslint/eslint-plugin
// "prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
// "plugin:prettier/recommended" // Should be last in the list. Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true // Allows for the parsing of JSX
},
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint",
"prettier"
],
"settings": {
"react": {
"pragma": "React",
"version": "detect"
}
},
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
// https://stackoverflow.com/a/53769213/9184658
"endOfLine":"auto"
}
]
// "semi": "error"
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "prettier"],
"settings": {
"react": {
"pragma": "React",
"version": "detect"
}
}
},
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
// https://stackoverflow.com/a/53769213/9184658
"endOfLine": "auto"
}
]
// "semi": "error"
}
}
14 changes: 8 additions & 6 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 90,
"tabWidth": 2
}
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 90,
"tabWidth": 2,
// https://stackoverflow.com/a/53769213/9184658
"endOfLine": "auto"
}
2 changes: 0 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
// "source.fixAll.eslint": true
// // "source.organizeImports": true,
// },

// Set the default
"editor.formatOnSave": true,
// Enable per-language
Expand All @@ -26,7 +25,6 @@
// "[jsonc]": {
// "editor.formatOnSave": true
// },

"editor.tabSize": 2,
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"search.exclude": {
Expand Down
26 changes: 16 additions & 10 deletions .yarn/sdks/prettier/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

const {existsSync} = require(`fs`);
const {createRequire, createRequireFromPath} = require(`module`);
const {resolve, dirname} = require(`path`);
const { existsSync } = require(`fs`);
const { createRequire, createRequireFromPath } = require(`module`);
const { resolve } = require(`path`);

const relPnpApiPath = "../../../.pnp.js";

Expand All @@ -15,16 +15,22 @@ if (existsSync(absPnpApiPath)) {
require(absPnpApiPath).setup();
}

const pnpifyResolution = require.resolve(`@yarnpkg/pnpify`, {paths: [dirname(absPnpApiPath)]});
if (typeof global[`__yarnpkg_sdk_is_using_pnpify__`] === `undefined`) {
Object.defineProperty(global, `__yarnpkg_sdk_is_using_pnpify__`, {configurable: true, value: true});
let pnpifyResolution;
try {
pnpifyResolution = absRequire.resolve(`@yarnpkg/pnpify`);
} catch (err) { }

process.env.NODE_OPTIONS += ` -r ${pnpifyResolution}`;
if (pnpifyResolution) {
if (typeof global[`__yarnpkg_sdk_is_using_pnpify__`] === `undefined`) {
Object.defineProperty(global, `__yarnpkg_sdk_is_using_pnpify__`, { configurable: true, value: true });

// Apply PnPify to the current process
absRequire(pnpifyResolution).patchFs();
process.env.NODE_OPTIONS += ` -r ${pnpifyResolution}`;

// Apply PnPify to the current process
absRequire(pnpifyResolution).patchFs();
}
}
}

// Defer to the real prettier/index.js your application uses
module.exports = absRequire(`prettier/index.js`);
module.exports = absRequire(`prettier/index.js`);

0 comments on commit 2d7a9b4

Please sign in to comment.