- What is Prettier?
- How it works?
- Why is there a Calypso fork?
- How do I use it?
- Is the whole Calypso code base formatted?
- How do we ensure that formatted files remain formatted?
/* eslint-disable no-console */ | |
export default function transformer( file, api ) { | |
const j = api.jscodeshift; | |
const ReactUtils = require( 'react-codemod/transforms/utils/ReactUtils' )( j ); | |
const root = j( file.source ); | |
ReactUtils.findReactES6ClassDeclaration( root ).forEach( checkEventHandlers ); | |
function checkEventHandlers( classPath ) { | |
// Find JSX attributes whose value is an expression container |
Post is a bag of attributes like title
, content
, metadata
or terms
.
Some are primitive values, others are complex objects.
The copy of the post saved on server is part of the common post state tree at
state.posts.queries
. In the UI code known as currentPost
or savedPost
.
Local edits are stored in state.posts.edits
. Modified attributes only, diff from the saved post.
Across the JavaScript community, the Prettier code formatter has become immensely popular over that last three years since it was originally released. It automatically performs high-quality formatting of your JavaScript code: when you press Save, your code is instantly formatted. This removes a distraction for contributors who write or review code, and allows them to focus on the more valuable aspects of their work without having to discuss the JavaScript WordPress Coding Standards so often. That's why we'd like to adopt it in the WordPress JavaScript code bases, too.
The official Prettier formatter is very opinionated and has very few options. The reasons are both technical and cultural. The complexity of the formatting algorithm would explode exponentially with too many options and their combinations, and a part of the project vision is to establish an unified JavaScript formattin
const globby = require( 'globby' ); | |
const fs = require( 'fs' ); | |
function list_dirs( glob ) { | |
return globby.sync( glob, { onlyDirectories: true } ); | |
} | |
const dirs = [ '.', './client', ...list_dirs( './apps/*' ), ...list_dirs( './packages/*' ) ]; | |
function pkg_name( dir ) { |