Skip to content

Commit

Permalink
Update dev practices
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Oct 15, 2023
1 parent 058a1ba commit 64381a2
Show file tree
Hide file tree
Showing 10 changed files with 2,141 additions and 5,890 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
open_collective: postcss
github: ai
78 changes: 78 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Test
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
full:
name: Node.js Latest Full
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 20
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run tests
run: pnpm test
short:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 18
- 16
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
old:
runs-on: ubuntu-latest
strategy:
matrix:
node-version:
- 14
- 12
- 10
name: Node.js ${{ matrix.node-version }} Quick
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: pnpm install --no-frozen-lockfile --ignore-scripts
- name: Run unit tests
run: pnpm unit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules/
yarn-error.log

coverage/
4 changes: 0 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
yarn-error.log
yarn.lock

*.test.js
coverage/
.github/
6 changes: 0 additions & 6 deletions .travis.yml

This file was deleted.

16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ function processSize (propPrefix, decl, list) {

module.exports = () => {
return {
postcssPlugin: 'postcss-size',
Declaration: {
'size': (decl, { list }) => {
if (decl.parent.name !== 'page') {
processSize('', decl, list)
}
'max-size': (decl, { list }) => {
processSize('max-', decl, list)
},

'min-size': (decl, { list }) => {
processSize('min-', decl, list)
},

'max-size': (decl, { list }) => {
processSize('max-', decl, list)
'size': (decl, { list }) => {
if (decl.parent.name !== 'page') {
processSize('', decl, list)
}
}
}
},
postcssPlugin: 'postcss-size'
}
}
module.exports.postcss = true
28 changes: 16 additions & 12 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
let postcss = require('postcss')
let { equal } = require('uvu/assert')
let { test } = require('uvu')
let postcss = require('postcss').default

let plugin = require('./')

async function run (input, output) {
let result = await postcss([plugin]).process(input, { from: undefined })
expect(result.css).toEqual(output)
expect(result.warnings()).toHaveLength(0)
function run(input, output, opts) {
let result = postcss([plugin(opts)]).process(input, { from: '/test.css' })
equal(result.css, output)
equal(result.warnings().length, 0)
}

it('sets width, height, min-width, min-height, max-width, max-height', async () => {
test('sets width, height, min-width, min-height, max-width, max-height', async () => {
await run('a{ size: 1px 2px; }', 'a{ width: 1px; height: 2px; }')
await run('a{ min-size: 1px 2px; }', 'a{ min-width: 1px; min-height: 2px; }')
await run('a{ max-size: 1px 2px; }', 'a{ max-width: 1px; max-height: 2px; }')
})

it('sets width and height by one value', async () => {
test('sets width and height by one value', async () => {
await run('a{ size: 1px; }', 'a{ width: 1px; height: 1px; }')
await run('a{ min-size: 1px; }', 'a{ min-width: 1px; min-height: 1px; }')
await run('a{ max-size: 1px; }', 'a{ max-width: 1px; max-height: 1px; }')
})

it('splits values by brackets', async () => {
test('splits values by brackets', async () => {
await run(
'a{ size: calc(4 * 2px) 2px; }',
'a{ width: calc(4 * 2px); height: 2px; }'
Expand All @@ -35,7 +37,7 @@ it('splits values by brackets', async () => {
)
})

it('prefix value', async () => {
test('prefix value', async () => {
await run(
'a{ size: -webkit-fit-content auto; }',
'a{ width: -webkit-fit-content; height: auto; }'
Expand All @@ -50,7 +52,7 @@ it('prefix value', async () => {
)
})

it('supports auto value', async () => {
test('supports auto value', async () => {
await run('a{ size: .98% auto; }', 'a{ width: .98%; height: auto; }')
await run(
'a{ min-size: .98% auto; }',
Expand All @@ -62,7 +64,7 @@ it('supports auto value', async () => {
)
})

it('supports !important', async () => {
test('supports !important', async () => {
await run(
'a{ size: 1px !important; }',
'a{ width: 1px !important; height: 1px !important; }'
Expand All @@ -77,9 +79,11 @@ it('supports !important', async () => {
)
})

it('not conflicts with @page size descriptor', async () => {
test('not conflicts with @page size descriptor', async () => {
await run(
'@page{ size: 4cm 6cm landscape; }',
'@page{ size: 4cm 6cm landscape; }'
)
})

test.run()
84 changes: 42 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,61 @@
"license": "MIT",
"repository": "postcss/postcss-size",
"scripts": {
"test": "jest-ci --coverage && eslint-ci ."
"unit": "uvu . '\\.test\\.js$'",
"test:coverage": "c8 pnpm unit",
"test:lint": "eslint .",
"test": "pnpm run /^test:/"
},
"engines": {
"node": ">=10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"peerDependencies": {
"postcss": "^8.1.0"
},
"devDependencies": {
"@logux/eslint-config": "^40.0.5",
"clean-publish": "^1.1.8",
"eslint": "^7.10.0",
"eslint-ci": "^1.0.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.0.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-let": "^1.1.0",
"eslint-plugin-prettierx": "^0.14.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-unicorn": "^22.0.0",
"husky": "^4.3.0",
"jest": "^26.4.2",
"jest-ci": "^0.1.1",
"lint-staged": "^10.4.0",
"postcss": "^8.1.0",
"postcss-sharec-config": "^0.1.8"
"@logux/eslint-config": "^52.0.1",
"c8": "^8.0.1",
"clean-publish": "^4.2.0",
"eslint": "^8.51.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-node-import": "^1.0.4",
"eslint-plugin-perfectionist": "^2.2.0",
"eslint-plugin-prefer-let": "^3.0.1",
"eslint-plugin-promise": "^6.1.1",
"postcss": "^8.4.31",
"uvu": "^0.5.6"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": "eslint --fix"
"prettier": {
"arrowParens": "avoid",
"jsxSingleQuote": false,
"quoteProps": "consistent",
"semi": false,
"singleQuote": true,
"trailingComma": "none"
},
"eslintConfig": {
"extends": "@logux/eslint-config"
},
"jest": {
"testEnvironment": "node",
"coverageThreshold": {
"global": {
"statements": 100
}
}
"c8": {
"exclude": [
"**/*.test.*"
],
"lines": 100,
"check-coverage": true
},
"sharec": {
"config": "postcss-sharec-config",
"version": "0.1.8"
"clean-publish": {
"cleanDocs": true
}
}
Loading

0 comments on commit 64381a2

Please sign in to comment.