Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: atlassian-labs/compiled
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: @compiled/react@0.16.0
Choose a base ref
...
head repository: atlassian-labs/compiled
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: @compiled/react@0.16.1
Choose a head ref
  • 11 commits
  • 41 files changed
  • 5 contributors

Commits on Oct 26, 2023

  1. Component declared styles (#1533)

    * chore: add example type test
    
    * feat: introduce stricter types part 1
    
    * chore: update docs
    
    * feat: wire up xcss prop
    
    * feat: adds xcss inline object support
    
    * feat: add support for simple collection of pass styles
    
    * chore: move
    
    * feat: expose cx util
    
    * chore: add failing test
    
    * chore: remove strict types and replace with direct cx usage
    
    * chore: fix types
    
    * chore: code review
    
    * feat: block at rules from xcss prop
    
    * chore: add css prop test
    
    * fix: update jsx namespace
    
    * chore: add tests and jsdoc
    
    * chore: code review
    
    * chore: update changeset message
    
    * chore: update type from code review
    
    * chore: fix spelling
    
    * chore: resolve code review comments
    
    * chore: remove unused
    
    * chore: fix types
    
    * chore: ensure selectors isnt available
    
    * feat: add scope option
    
    ---------
    
    Co-authored-by: Alex Hinds <ahinds@atlassian.com>
    itsdouges and Alex Hinds authored Oct 26, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    reakaleek Jan Calanog
    Copy the full SHA
    4caa678 View commit details
  2. XCSS prop options arg (#1541)

    * fix: Fixes empty inline object throwing
    
    * feat: add type helpers to flag properties and pseudos as required
    
    * chore: update
    
    * chore: update jsdoc
    itsdouges authored Oct 26, 2023
    Copy the full SHA
    dccb71e View commit details

Commits on Oct 30, 2023

  1. chore(deps): update definitelytyped (#1542)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 30, 2023
    Copy the full SHA
    0c7570b View commit details
  2. chore(deps): update dependency jscodeshift to ^0.15.1 (#1543)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 30, 2023
    Copy the full SHA
    29bc13c View commit details
  3. chore(deps): update dependency resolve to ^1.22.8 (#1544)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Oct 30, 2023
    Copy the full SHA
    e51db08 View commit details

Commits on Nov 2, 2023

  1. No suppress XCSS prop lint rule (#1545)

    * chore: init new lint rule
    
    * feat: add no-suppress-xcss rule logic
    
    * fix: lint indiviudal properties
    
    * chore: resolve code review comments
    
    * chore: changeset
    itsdouges authored Nov 2, 2023
    Copy the full SHA
    351dbc2 View commit details
  2. XCSS prop no js lint (#1547)

    * feat: add no-js-xcss
    
    * chore: changeset
    
    * chore: fix
    
    * chore: resolve code review comments
    itsdouges authored Nov 2, 2023
    Copy the full SHA
    2010cde View commit details
  3. XCSS prop local cx lint (#1548)

    * chore: init
    
    * chore: add to configs
    
    * feat: add local-cx-xcss rule
    
    * chore: changeset
    
    * chore: fix
    
    * chore: fix readme
    
    * chore: now
    
    * chore: fix incorrect names
    
    * chore: resolve code review comments
    
    * chore: fix white space
    itsdouges authored Nov 2, 2023
    Copy the full SHA
    157e7ee View commit details
  4. Fix XCSS prop collecting more styles than expected (#1549)

    * fix: bail out of xcss prop transform when no sheets
    
    * fix: fix xcss prop collecting all styles instead of ones used
    
    * chore: add test case
    itsdouges authored Nov 2, 2023
    Copy the full SHA
    4de6927 View commit details

Commits on Nov 3, 2023

  1. Update jsx-pragma rule to ensure it exists when using xcss prop (#1550)

    * feat: update jsx-pragma rule to ensure it exists when using xcss prop
    
    * chore: changeset
    
    * chore: apply fixer
    
    * fix: use test over exec
    itsdouges authored Nov 3, 2023
    Copy the full SHA
    9e75ff2 View commit details
  2. Version Packages (#1540)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
    atlas-dst-bot and github-actions[bot] authored Nov 3, 2023
    Copy the full SHA
    2395a10 View commit details
Showing with 2,007 additions and 381 deletions.
  1. +2 −2 package.json
  2. +1 −1 packages/babel-plugin-strip-runtime/package.json
  3. +56 −0 packages/babel-plugin/CHANGELOG.md
  4. +5 −5 packages/babel-plugin/package.json
  5. +9 −0 packages/babel-plugin/src/babel-plugin.ts
  6. +6 −1 packages/babel-plugin/src/types.ts
  7. +308 −0 packages/babel-plugin/src/xcss-prop/__tests__/transformation.test.ts
  8. +124 −0 packages/babel-plugin/src/xcss-prop/index.ts
  9. +2 −2 packages/codemods/package.json
  10. +9 −0 packages/eslint-plugin/CHANGELOG.md
  11. +3 −3 packages/eslint-plugin/package.json
  12. +5 −2 packages/eslint-plugin/src/configs/recommended.ts
  13. +9 −3 packages/eslint-plugin/src/index.ts
  14. +34 −0 packages/eslint-plugin/src/rules/jsx-pragma/__tests__/rule.test.ts
  15. +66 −49 packages/eslint-plugin/src/rules/jsx-pragma/index.ts
  16. +31 −0 packages/eslint-plugin/src/rules/local-cx-xcss/README.md
  17. +94 −0 packages/eslint-plugin/src/rules/local-cx-xcss/__tests__/rule.test.ts
  18. +53 −0 packages/eslint-plugin/src/rules/local-cx-xcss/index.ts
  19. +19 −0 packages/eslint-plugin/src/rules/no-js-xcss/README.md
  20. +29 −0 packages/eslint-plugin/src/rules/no-js-xcss/__tests__/rule.test.ts
  21. +29 −0 packages/eslint-plugin/src/rules/no-js-xcss/index.ts
  22. +18 −0 packages/eslint-plugin/src/rules/no-suppress-xcss/README.md
  23. +143 −0 packages/eslint-plugin/src/rules/no-suppress-xcss/__tests__/rule.test.ts
  24. +79 −0 packages/eslint-plugin/src/rules/no-suppress-xcss/index.ts
  25. +1 −1 packages/eslint-plugin/src/utils/index.ts
  26. +1 −0 packages/eslint-plugin/src/utils/is-compiled-import.ts
  27. +1 −1 packages/jest/package.json
  28. +1 −1 packages/parcel-transformer/package.json
  29. +56 −0 packages/react/CHANGELOG.md
  30. +2 −2 packages/react/package.json
  31. +19 −33 packages/react/src/css-map/index.ts
  32. +0 −59 packages/react/src/css-map/pseudos.ts
  33. +1 −0 packages/react/src/css/__tests__/types.test.ts
  34. +1 −0 packages/react/src/index.ts
  35. +8 −1 packages/react/src/jsx/jsx-local-namespace.ts
  36. +1 −1 packages/react/src/runtime/ac.ts
  37. +1 −1 packages/react/src/runtime/ax.ts
  38. +68 −0 packages/react/src/types.ts
  39. +294 −0 packages/react/src/xcss-prop/__tests__/xcss-prop.test.tsx
  40. +174 −0 packages/react/src/xcss-prop/index.ts
  41. +244 −213 yarn.lock
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -79,8 +79,8 @@
"@types/eslint": "^8.44.0",
"@types/jest": "^27.5.2",
"@types/node": "^18.17.14",
"@types/react": "^17.0.62",
"@types/react-dom": "^17.0.20",
"@types/react": "^17.0.69",
"@types/react-dom": "^17.0.22",
"@types/svgo": "^2.6.4",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
2 changes: 1 addition & 1 deletion packages/babel-plugin-strip-runtime/package.json
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
},
"devDependencies": {
"@compiled/babel-plugin": "*",
"@types/babel__core": "^7.20.1",
"@types/babel__core": "^7.20.3",
"prettier": "^2.8.8"
}
}
56 changes: 56 additions & 0 deletions packages/babel-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# @compiled/babel-plugin

## 0.24.2

### Patch Changes

- 4caa6784: The xcss prop is now available.
Declare styles your component takes with all other styles marked as violations
by the TypeScript compiler. There are two primary use cases for xcss prop:

- safe style overrides
- inverting style declarations

Interverting style declarations is interesting for platform teams as
it means products only pay for styles they use as they're now the ones who declare
the styles!

The `XCSSProp` type has generics which must be defined — of which should be what you
explicitly want to maintain as API. Use `XCSSAllProperties` and `XCSSAllPseudos` types
to enable all properties and pseudos.

```tsx
import { type XCSSProp } from '@compiled/react';

interface MyComponentProps {
// Color is accepted, all other properties / pseudos are considered violations.
xcss?: XCSSProp<'color', never>;

// Only backgrond color and hover pseudo is accepted.
xcss?: XCSSProp<'backgroundColor', '&:hover'>;

// All properties are accepted, all pseudos are considered violations.
xcss?: XCSSProp<XCSSAllProperties, never>;

// All properties are accepted, only the hover pseudo is accepted.
xcss?: XCSSProp<XCSSAllProperties, '&:hover'>;
}

function MyComponent({ xcss }: MyComponentProps) {
return <div css={{ color: 'var(--ds-text-danger)' }} className={xcss} />;
}
```

The xcss prop works with static inline objects and the [cssMap](https://compiledcssinjs.com/docs/api-cssmap) API.

```tsx
// Declared as an inline object
<Component xcss={{ color: 'var(--ds-text)' }} />;

// Declared with the cssMap API
const styles = cssMap({ text: { color: 'var(--ds-text)' } });
<Component xcss={styles.text} />;
```

To concatenate and conditonally apply styles use the `cssMap` and `cx` functions.

- dccb71e0: Adds third generic for XCSSProp type for declaring what properties and pseudos should be required.

## 0.24.1

### Patch Changes
10 changes: 5 additions & 5 deletions packages/babel-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@compiled/babel-plugin",
"version": "0.24.1",
"version": "0.24.2",
"description": "A familiar and performant compile time CSS-in-JS library for React.",
"homepage": "https://compiledcssinjs.com/docs/pkg-babel-plugin",
"bugs": "https://github.com/atlassian-labs/compiled/issues/new?assignees=&labels=bug&template=bug_report.md",
@@ -31,14 +31,14 @@
"@compiled/css": "^0.12.0",
"@compiled/utils": "^0.8.0",
"@emotion/is-prop-valid": "^1.2.1",
"resolve": "^1.22.4"
"resolve": "^1.22.8"
},
"devDependencies": {
"@compiled-private/module-a": "^0.1.0",
"@compiled/benchmark": "1.1.0",
"@types/babel__core": "^7.20.1",
"@types/benchmark": "^2.1.2",
"@types/resolve": "^1.20.2",
"@types/babel__core": "^7.20.3",
"@types/benchmark": "^2.1.4",
"@types/resolve": "^1.20.4",
"benchmark": "^2.1.4",
"prettier": "^2.8.8",
"ts-node": "^10.9.1",
9 changes: 9 additions & 0 deletions packages/babel-plugin/src/babel-plugin.ts
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import {
isCompiledCSSMapCallExpression,
} from './utils/is-compiled';
import { normalizePropsUsage } from './utils/normalize-props-usage';
import { visitXcssPropPath } from './xcss-prop';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageJson = require('../package.json');
@@ -65,6 +66,8 @@ export default declare<State>((api) => {
paths: [state.opts.root ?? this.cwd],
}));
}

this.transformCache = new WeakMap();
},
visitor: {
Program: {
@@ -87,6 +90,11 @@ export default declare<State>((api) => {
}
}
}

if (!state.compiledImports && /(x|X)css={/.test(file.code)) {
// xcss prop was found turn on Compiled
state.compiledImports = {};
}
},
exit(path, state) {
if (!state.compiledImports) {
@@ -229,6 +237,7 @@ export default declare<State>((api) => {
return;
}

visitXcssPropPath(path, { context: 'root', state, parentPath: path });
visitCssPropPath(path, { context: 'root', state, parentPath: path });
},
},
7 changes: 6 additions & 1 deletion packages/babel-plugin/src/types.ts
Original file line number Diff line number Diff line change
@@ -144,14 +144,19 @@ export interface State extends PluginPass {
includedFiles: string[];

/**
* Holds a record of currently evaluated CSS Map and its sheets in the module.
* Holds a record of evaluated `cssMap()` calls with their compiled style sheets in the current pass.
*/
cssMap: Record<string, string[]>;

/**
* A custom resolver used to statically evaluate import declarations
*/
resolver?: Resolver;

/**
* Holds paths that have been transformed that we can ignore.
*/
transformCache: WeakMap<NodePath<any>, true>;
}

interface CommonMetadata {
Loading