Skip to content

Commit

Permalink
v0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aMarCruz committed Feb 8, 2021
1 parent 07f0124 commit 67e1c54
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 93 deletions.
18 changes: 2 additions & 16 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
{
"alignObjectProperties": false,
"alignTernaryLines": false,
"offsetTernaryExpressions": true,
"arrowParens": "avoid",
"bracketSpacing": true,
"breakBeforeElse": false,
"breakLongMethodChains": true,
"endOfLine": "lf",
"generatorStarSpacing": true,
"htmlWhitespaceSensitivity": "css",
"indentChains": true,
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"parenSpacing": false,
"printWidth": 92,
"proseWrap": "preserve",
"quoteProps": "consistent",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"spaceBeforeFunctionParen": true,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"htmlVoidTags": true,
"yieldStarSpacing": true
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog of eslint-plugin-prettierx

## \[0.17.0] - 2021-02-07

### Added

- Remove obsolete options and add new ones from PrettierX 0.17, see [options removed]('prettierx: Clearing prettier cache...')

### Changed

- Use default value (`false`) for the `breakLongMethodChains` option (sorry).
- Updated PrettierX to 0.17.0

### Removed

- Remove the 'prettierx: Clearing prettier cache...' message.
- Remove obsolete folder of the fake prettier package.

### Fixed

- Fix #7 Unable to use standardx anymore

## \[0.16.0] - 2021-01-19

### Added
Expand Down
78 changes: 36 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,17 @@ These are the prettierx [options](#options) used for each preset:
|   | Prettier 2.x | standardx | standardize |
| -------------------------- | ------------ | ----------- | ------------ |
| `alignObjectProperties` | false | false | false |
| `alignTernaryLines` | true | false | false |
| `offsetTernaryExpressions` | false | true | true |
| `arrowParens` | "always" | "avoid" | "avoid" |
| `bracketSpacing` | true | true | true |
| `breakBeforeElse` | false | false | false |
| `breakLongMethodChains` | false | false | true |
| `breakLongMethodChains` | false | false | false |
| `endOfLine` | "lf" | "lf" | "lf" |
| `generatorStarSpacing` | false | true | true |
| `indentChains` | true | true | true |
| `insertPragma` | false | - | false |
| `jsxBracketSameLine` | false | false | false |
| `jsxSingleQuote` | false | true | false |
| `parenSpacing` | false | false | false |
| `parser` | "babel" | "babel" | "babel" |
| `printWidth` | 80 | 80 | 92 |
| `quoteProps` | "as-needed" | "as-needed" | "consistent" |
Expand Down Expand Up @@ -282,45 +281,40 @@ These are the same for the "standardx" and "standardize" presets, except `usePre

Use `false` only for test the settings, leave the default for normal use.

## Supported Options

All allowed, but not all makes sense.

### Prettier Options

| Property | Type | Default | Notes |
| ---------------------------- | ------- | ----------- | ---------------------------------------------------------------------------------------------------------------- |
| `printWidth` | integer | 80 | Specify the line length that the printer will wrap on. |
| `tabWidth` | integer | 2 | Specify the number of spaces per indentation-level. |
| `useTabs` | boolean | false | Indent lines with tabs instead of spaces. |
| `semi` | boolean | true | Print semicolons at the ends of statements. |
| `singleQuote` | boolean | false | Use single quotes instead of double quotes. |
| `jsxSingleQuote` | boolean | false | Use single quotes instead of double quotes in JSX. |
| `quoteProps` | string | "as-needed" | Change when properties in objects are quoted. Valid options: 'as-needed', 'consistent', 'preserve'. |
| `trailingComma` | enum | "none" | (none, es5, all) Print trailing commas wherever possible when multi-line. |
| `bracketSpacing` | boolean | true | Print spaces between brackets in object literals. |
| `jsxBracketSameLine` | boolean | false | Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line. |
| `arrowParens` | enum | "avoid" | (avoid, always) Include parentheses around a sole arrow function parameter. |
| `parser` | string | "babel" | Specify which parser to use. Yo can also pass an already `require`d parser. |
| `requirePragma` | boolean | false | Restrict to only format files that contain a special comment (`@prettier` or `@format`). |
| `insertPragma` | boolean | false | Insert a special `@format` marker at the top of files that have been formatted. |
| `endOfLine` | enum | "auto" | (auto, lf, crlf, cr) End-of-line type. "auto" normalises the EOLs by looking at what's used after the first line |
| `embeddedLanguageFormatting` | boolean | "auto" | Control whether Prettier formats quoted code embedded in the file. |

### Prettierx Extensions

| Property | Type | Default | Notes |
| -------------------------- | ------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `alignObjectProperties` | boolean | false | Align colons in multiline object literals (not applied with any of the JSON parsers). |
| `spaceBeforeFunctionParen` | boolean | false | Put a space before function parenthesis. |
| `generatorStarSpacing` | boolean | false | Add spaces around the star (\*) in generator functions. |
| `yieldStarSpacing` | boolean | false | Add spaces around the star (\*) in `yield` expressions. |
| `parenSpacing` | boolean | false | Inserts extra spaces inside parentheses, the way how projects in the WordPress ecosystem (Calypso, Gutenberg, etc.). |
| `alignTernaryLines` | boolean | true | Align ternary lines in case of multiline ternery term (Should be disabled for consistency with ESLint/StandardJS behavior. |
| `indentChains` | boolean | true | Print indents at the start of chained calls. |
| `breakBeforeElse` | boolean | false | Always add a line break before else. |
| `htmlVoidTags` | boolean | false | Format void HTML elements as void tags. |
| `breakLongMethodChains` | boolean | false | Break method chains with more than 3 method calls, like Prettier 1.x. |
### Options

PrettierX ships with a handful of customizable format options, usable in both the CLI and API.

For the full list of options please see the [Options of PrettierX](https://github.com/brodybits/prettierx/blob/dev/docs/options.md).

These are just the _additional_ PrettierX options and its default values:

| Property | Default |
| ------------------------ | ------- |
| alignObjectProperties | false |
| arrayBracketSpacing | false |
| breakBeforeElse | false |
| breakLongMethodChains | false |
| computedPropertySpacing | false |
| cssParenSpacing | false |
| exportCurlySpacing | true |
| generatorStarSpacing | false |
| graphqlCurlySpacing | true |
| htmlVoidTags | false |
| importCurlySpacing | true |
| importFormatting | "auto" |
| indentChains | true |
| objectCurlySpacing | true |
| offsetTernaryExpressions | false |
| spaceBeforeFunctionParen | false |
| spaceInParens | false |
| spaceUnaryOps | false |
| templateCurlySpacing | false |
| typeAngleBracketSpacing | false |
| typeBracketSpacing | false |
| typeCurlySpacing | true |
| yamlBracketSpacing | true |
| yieldStarSpacing | false |

## VS Code ESLint

Expand Down
6 changes: 2 additions & 4 deletions lib/configs/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
default: {},
standardize: {
alignObjectProperties: false,
alignTernaryLines: false,
offsetTernaryExpressions: true,
arrowParens: 'avoid',
bracketSpacing: true,
breakBeforeElse: false,
Expand All @@ -17,7 +17,6 @@ module.exports = {
insertPragma: false,
jsxBracketSameLine: false,
jsxSingleQuote: false,
parenSpacing: false,
printWidth: 92,
proseWrap: 'preserve',
quoteProps: 'consistent',
Expand All @@ -32,7 +31,7 @@ module.exports = {
},
standardx: {
alignObjectProperties: false,
alignTernaryLines: false,
offsetTernaryExpressions: true,
arrowParens: 'avoid',
bracketSpacing: true,
breakBeforeElse: false,
Expand All @@ -43,7 +42,6 @@ module.exports = {
insertPragma: false,
jsxBracketSameLine: false,
jsxSingleQuote: true,
parenSpacing: false,
printWidth: 80,
proseWrap: 'preserve',
quoteProps: 'as-needed',
Expand Down
44 changes: 44 additions & 0 deletions lib/configs/prettierrc.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"alignObjectProperties": false,
"arrayBracketSpacing": false,
"breakBeforeElse": false,
"breakLongMethodChains": false,
"computedPropertySpacing": false,
"cssParenSpacing": false,
"exportCurlySpacing": true,
"generatorStarSpacing": false,
"graphqlCurlySpacing": true,
"htmlVoidTags": false,
"importCurlySpacing": true,
"importFormatting": "auto",
"indentChains": true,
"objectCurlySpacing": true,
"offsetTernaryExpressions": false,
"spaceBeforeFunctionParen": false,
"spaceInParens": false,
"spaceUnaryOps": false,
"templateCurlySpacing": false,
"typeAngleBracketSpacing": false,
"typeBracketSpacing": false,
"typeCurlySpacing": true,
"yamlBracketSpacing": true,
"yieldStarSpacing": false,
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": false,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"requirePragma": false,
"insertPragma": false,
"proseWrap": "preserve",
"htmlWhitespaceSensitivity": "css",
"vueIndentScriptAndStyle": false,
"endOfLine": "lf",
"embeddedLanguageFormatting": "off"
}
1 change: 0 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ module.exports = {
const source = sourceCode.text

if (_prettier && _prettier.clearConfigCache && !_cacheCleared) {
console.log('Prettier: Clearing config cache ...')
_prettier.clearConfigCache()
_cacheCleared = true
}
Expand Down
94 changes: 82 additions & 12 deletions lib/schemas/prettierx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,106 @@
"description": "Align colons in multiline object literals (not applied with any of the JSON parsers).",
"type": "boolean"
},
"breakLongMethodChains": {
"description": "Break method chains with more than 3 method calls, like Prettier 1.x.",
"type": "boolean"
},
"spaceBeforeFunctionParen": {
"description": "Put a space before function parenthesis.",
"description": "Put a space before function parenthesis in all declarations (similar to the corresponding eslint option).",
"type": "boolean"
},
"generatorStarSpacing": {
"description": "Add spaces around the star (*) in generator functions (before and after - from eslint).",
"description": "Put spaces around the star (*) in generator functions (before and after - similar to the corresponding eslint option).",
"type": "boolean"
},
"yieldStarSpacing": {
"description": "Add spaces around the star (*) in yield* expressions (before and after - from eslint).",
"type": "boolean"
},
"parenSpacing": {
"description": "Inserts extra spaces inside parentheses, the way how projects in the WordPress ecosystem.",
"breakBeforeElse": {
"description": "Always add a line break before else.",
"type": "boolean"
},
"indentChains": {
"description": "Print indents at the start of chained calls.",
"importFormatting": {
"description": "Formatting of import statements, may be oneline to avoid conflict with VSCode 'Organize Imports' feature.",
"oneOf": [
{
"enum": ["auto"],
"description": "automatic formatting, like Prettier."
},
{
"enum": ["oneline"],
"description": "keep import statements on one line."
}
]
},
"htmlVoidTags": {
"description": "Format void HTML elements as void tags.",
"type": "boolean"
},
"alignTernaryLines": {
"description": "Align ternary lines in case of multiline ternery term (default behavior, conflict with standard)",
"arrayBracketSpacing": {
"description": "Put spaces between array brackets (similar to the corresponding eslint option). Status: experimental, with limited testing.",
"type": "boolean"
},
"htmlVoidTags": {
"description": "Format void HTML elements as void tags.",
"cssParenSpacing": {
"description": "Put spaces between parens in CSS, WordPress style. Status: experimental, with limited testing.",
"type": "boolean"
},
"breakLongMethodChains": {
"description": "Break method chains with more than 3 method calls, like Prettier 1.x.",
"computedPropertySpacing": {
"description": "Put spaces between computed property brackets (similar to the corresponding eslint option). Status: experimental, with limited testing.",
"type": "boolean"
},
"offsetTernaryExpressions": {
"description": "Indent and align ternary expression branches more consistently with 'Standard JS' (similar to the corresponding eslint option).",
"type": "boolean"
},
"spaceUnaryOps": {
"description": "Put spaces after unary operator symbols, except in the middle of !! (similar to the corresponding eslint option)",
"type": "boolean"
},
"spaceInParens": {
"description": "Print spaces in between parens, WordPress style (similar to the corresponding eslint option). Not recommended in combination with the default arrowParens: 'always' option.",
"type": "boolean"
},
"templateCurlySpacing": {
"description": "Put spaces between template curly brackets (similar to the corresponding eslint option). Status: experimental, with limited testing.",
"type": "boolean"
},
"typeAngleBracketSpacing": {
"description": "Put spaces between type angle brackets. Status: experimental, with limited testing.",
"type": "boolean"
},
"typeBracketSpacing": {
"description": "Put spaces between type brackets. Status: experimental, with limited testing.",
"type": "boolean"
},
"exportCurlySpacing": {
"description": "Put or disable spaces between export curly braces.",
"type": "boolean"
},
"importCurlySpacing": {
"description": "Put or disable spaces between import curly braces.",
"type": "boolean"
},
"graphqlCurlySpacing": {
"description": "Put or disable spaces between curly braces for GraphQL.",
"type": "boolean"
},
"yamlBracketSpacing": {
"description": "Put or disable spaces between brackets / curly braces for YAML.",
"type": "boolean"
},
"typeCurlySpacing": {
"description": "Put or disable spaces between type curly braces.",
"type": "boolean"
},

"indentChains": {
"description": "Print indents at the start of chained calls.",
"type": "boolean"
},
"objectCurlySpacing": {
"description": "Disable spaces between object curly braces (similar to the corresponding eslint option).",
"type": "boolean"
}
}
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-prettierx",
"version": "0.16.0",
"version": "0.17.0",
"description": "Format your code with ESLint using Prettierx, with presets for Prettier and StandardJS",
"keywords": [
"eslint",
Expand Down Expand Up @@ -37,15 +37,15 @@
"dependencies": {
"eslint-config-prettier": "~7.2.0",
"prettier-linter-helpers": "~1.0.0",
"prettierx": "~0.16.0"
"prettierx": "~0.17.0"
},
"devDependencies": {
"@types/eslint": "~7.2.6",
"@types/node": "~14.14.22",
"@types/prettier": "~2.1.6",
"@typescript-eslint/eslint-plugin": "~4.14.0",
"@typescript-eslint/parser": "~4.14.0",
"eslint": "~7.18.0",
"@types/node": "~14.14.25",
"@types/prettier": "~2.2.0",
"@typescript-eslint/eslint-plugin": "~4.14.2",
"@typescript-eslint/parser": "~4.14.2",
"eslint": "~7.19.0",
"eslint-config-standardize": "~0.7.2",
"typescript": "~4.1.3"
},
Expand Down
Loading

0 comments on commit 67e1c54

Please sign in to comment.