Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/style-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Static Analysis (Style JS/CSS)

on:
pull_request:
paths:
- 'wordpress.org/public_html/style/**.js'
- 'wordpress.org/public_html/style/**.css'
- 'wordpress.org/public_html/style/package.json'
- 'wordpress.org/public_html/style/package-lock.json'
- 'wordpress.org/public_html/style/.prettierignore'
- .github/workflows/style-lint.yml
push:
branches: [trunk]
paths:
- 'wordpress.org/public_html/style/**.js'
- 'wordpress.org/public_html/style/**.css'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Style Coding Standards
runs-on: ubuntu-latest

defaults:
run:
working-directory: wordpress.org/public_html/style

steps:
- uses: actions/checkout@v7

- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
cache-dependency-path: wordpress.org/public_html/style/package-lock.json

- name: Install dependencies
run: npm ci

- name: Lint JavaScript
run: npm run lint:js

- name: Lint CSS
run: npm run lint:css

- name: Check formatting
run: npx prettier --check .

# Generated files (wp4-rtl.css, js/navigation.min.js) are committed, so a
# source edit without a rebuild ships stale output. Rebuild and fail on drift.
- name: Check generated files are up to date
run: |
npm run build
git diff --exit-code -- .
3 changes: 1 addition & 2 deletions trac.wordpress.org/templates/site_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<script src="https://s.w.org/style/trac/jquery.caret.min.js?ver=2015-02-01"></script>
<script src="https://s.w.org/style/trac/jquery.atwho.min.js?ver=1.0.1"></script>
<script src="https://s.w.org/style/trac/wp-trac.js?${scripts_version}"></script>
<script src="https://s.w.org/style/trac/wp-trac-jinja-compat.js?${scripts_version}"></script>

## Check for security buzzwords on new tickets
# if req.path_info == '/newticket':
Expand All @@ -49,7 +48,7 @@
</div>
<script>
function wp_trac_auth_check() {
$.ajax( '${href('/')}' ).success( function( data ) {
$.ajax( '${href('/')}' ).done( function( data ) {
var addClass = -1 !== data.indexOf( '<!--TRAC_WP_USER_IS_LOGGED_IN-->' );
$( '#wp-auth-check-wrap' ).toggleClass( 'hidden', addClass );
});
Expand Down
1 change: 0 additions & 1 deletion trac.wordpress.org/templates/site_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="https://s.w.org/wp-includes/css/dashicons.min.css?20150710" type="text/css"/>
<link rel="stylesheet" type="text/css" href="https://s.w.org/style/trac/wp-trac.css?${scripts_version}"/>
<link rel="stylesheet" type="text/css" href="https://s.w.org/style/trac/wp-trac-jinja-compat.css?${scripts_version}"/>
# if req.is_authenticated:
<link rel="stylesheet" href="https://s.w.org/wp-includes/css/wp-auth-check.css?ver=3.9-alpha" type="text/css" media="all"/>
# endif
Expand Down
2 changes: 0 additions & 2 deletions wordpress.org/public_html/style/.jshintignore

This file was deleted.

25 changes: 0 additions & 25 deletions wordpress.org/public_html/style/.jshintrc

This file was deleted.

4 changes: 4 additions & 0 deletions wordpress.org/public_html/style/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/*.min.js
*.css
package-lock.json
trac/common/
12 changes: 12 additions & 0 deletions wordpress.org/public_html/style/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Prettier configuration.
*
* The default @wordpress/prettier-config, with a wider line length.
*/

const wpConfig = require( '@wordpress/prettier-config' );

module.exports = {
...wpConfig,
printWidth: 120,
};
12 changes: 12 additions & 0 deletions wordpress.org/public_html/style/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Vendored copy of Trac's own assets.
trac/common/

# Generated from wp4.css by `npm run build:css`.
wp4-rtl.css

# Frozen legacy stylesheets, kept byte-for-byte as served.
blog-wp4.css
codex-wp4.css
forum-ie7.css
forum-wp4.css
forum-wp4-rtl.css
16 changes: 16 additions & 0 deletions wordpress.org/public_html/style/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
extends: [ '@wordpress/stylelint-config' ],
rules: {
/*
* The stylesheets style Trac's and WordPress.org's existing markup, whose
* ids and class names are not ours to rename, and they predate these
* rules — reordering or merging selectors to satisfy them would change
* the cascade, as would converting the em/rem line-heights.
*/
'declaration-property-unit-allowed-list': null,
'no-descending-specificity': null,
'no-duplicate-selectors': null,
'selector-class-pattern': null,
'selector-id-pattern': null,
},
};
34 changes: 34 additions & 0 deletions wordpress.org/public_html/style/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Agent instructions — wordpress.org/public_html/style/

Everything in this directory is served publicly, as-is, from `https://s.w.org/style/`.
Changes are committed to meta.svn and then deployed from a Dotorg sandbox — committing alone
does not make them live. See README.md for the full file inventory and development flow, and
trac/README.md for the Trac-specific workflow.

## Commands

Run from this directory (`npm install` first):

- `npm run build` — rebuild all generated files
- `npm run build:css` — regenerate `wp4-rtl.css` from `wp4.css`
- `npm run build:js` — rebuild `js/navigation.min.js`
- `npm run format` — Prettier over all sources
- `npm run lint:js` — ESLint (stock `@wordpress/scripts` ruleset) over `js/` and `trac/`

## Rules

- Never hand-edit generated files: `wp4-rtl.css`, `js/navigation.min.js`. Edit the source
(`wp4.css`, `js/navigation.js`), rebuild, and commit source and output together.
- Write any vendor prefix a property still needs by hand — supported browsers
(`@wordpress/browserslist-config`) rarely require them. After editing `wp4.css`, run
`npm run build:css` to keep `wp4-rtl.css` in sync.
- Never edit vendored files: `trac/common/`, `trac/jquery.atwho.min.js`,
`trac/jquery.caret.min.js`. They are excluded from linting and formatting.
- Code style is the stock `@wordpress/scripts` configuration with one override:
`printWidth: 120` (`.prettierrc.js`). Run `npm run format` and `npm run lint:js` before
committing; both must pass clean.
- The files in `trac/` run live on `*.trac.wordpress.org` with no build step. Once a change
to them is committed AND deployed from a Dotorg sandbox, `scripts_version` must be bumped
in BOTH `trac.wordpress.org/templates/site_head.html` and `site_footer.html` in a
follow-up commit, or browsers keep serving the cached old version. The bump itself is
picked up automatically by the hosts' SVN refreshes. Details in trac/README.md.
1 change: 1 addition & 0 deletions wordpress.org/public_html/style/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
139 changes: 0 additions & 139 deletions wordpress.org/public_html/style/Gruntfile.js

This file was deleted.

51 changes: 51 additions & 0 deletions wordpress.org/public_html/style/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# WordPress.org Global Styles

Global stylesheets, scripts, and images for WordPress.org, served from
`https://s.w.org/style/`. Changes are committed to meta.svn and then deployed
from a Dotorg sandbox; see [Deployment](#deployment).

## Files

| File | Description |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `wp4.css` | The main WordPress.org stylesheet. Edited by hand; vendor prefixes are hand-written on the rare occasion a property still needs one. |
| `wp4-rtl.css` | RTL version of `wp4.css`. Generated — do not edit by hand. |
| `blog-wp4.css`, `codex-wp4.css`, `forum-wp4.css`, `forum-wp4-rtl.css`, `forum-ie7.css` | Standalone legacy stylesheets for individual properties. Edited by hand, not part of the build. |
| `js/navigation.js` | Navigation menu toggle and keyboard-navigation support. Source. |
| `js/navigation.min.js` | Minified build of `navigation.js`. Generated — do not edit by hand. |
| `images/`, `header-logo.png` | Static images. |
| `trac/` | Customizations for the `*.trac.wordpress.org` installs. See [trac/README.md](trac/README.md). |

## Development

Tooling is based on [`@wordpress/scripts`](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/).
Requires Node.js and npm.

```
npm install
```

| Command | Description |
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `npm run build` | Runs `build:css` and `build:js`. |
| `npm run build:css` | Regenerates `wp4-rtl.css` from `wp4.css` via `bin/build-rtl.js`. The RTL pass includes a plugin that swaps Dashicons left/right arrow glyphs, which RTLCSS cannot infer from the CSS itself. |
| `npm run build:js` | Builds `js/navigation.js` into `js/navigation.min.js` (webpack via `wp-scripts build`, see `webpack.config.js`). Transpilation targets come from the `browserslist` field in `package.json`, which extends the official `@wordpress/browserslist-config`. |
| `npm run format` | Formats all source files with Prettier (`wp-scripts format`). |
| `npm run lint:js` | Lints all JavaScript, including `trac/`, with the stock `@wordpress/scripts` ESLint configuration. Vendored files (`*.min.js`, `trac/common/`) are excluded. |

Code in this directory adheres to the default `@wordpress/scripts` style,
with one local override: `.prettierrc.js` extends the stock
`@wordpress/prettier-config` with a line length of 120. Generated files
(`wp4-rtl.css`, `js/navigation.min.js`) are committed, since
the CDN serves this directory as-is; rebuild and commit them together with
their sources.

## Deployment

Commit changes to the meta SVN repository as normal, then deploy the files
from a Dotorg sandbox — committing alone does not make them live on
`s.w.org`. Consumers reference these files with cache-busting query strings,
so a change to an existing file also needs the referencing version string
bumped once the file is deployed; the bump itself is picked up automatically
by the hosts' SVN refreshes. See [trac/README.md](trac/README.md) for how
that works for the Trac assets.
Loading
Loading