Skip to content

Commit a7f5b76

Browse files
authored
Merge pull request #4 from startupjs/upgrade-to-upstream-2.1.0
Upgrade to upstream 2.1.0
2 parents 5dc4ec0 + 64d75fe commit a7f5b76

File tree

12 files changed

+4396
-3933
lines changed

12 files changed

+4396
-3933
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ "master" ]
20+
schedule:
21+
- cron: '25 21 * * 2'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'javascript' ]
36+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
38+
39+
steps:
40+
- name: Checkout repository
41+
uses: actions/checkout@v3
42+
43+
# Initializes the CodeQL tools for scanning.
44+
- name: Initialize CodeQL
45+
uses: github/codeql-action/init@v2
46+
with:
47+
languages: ${{ matrix.language }}
48+
# If you wish to specify custom queries, you can do so here or in a config file.
49+
# By default, queries listed here will override any specified in a config file.
50+
# Prefix the list here with "+" to use these queries and those in the config file.
51+
52+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
53+
# queries: security-extended,security-and-quality
54+
55+
56+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
57+
# If this step fails, then you should remove it and run the build manually (see below)
58+
- name: Autobuild
59+
uses: github/codeql-action/autobuild@v2
60+
61+
# ℹ️ Command-line programs to run using the OS shell.
62+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
63+
64+
# If the Autobuild fails above, remove it and uncomment the following three lines.
65+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
66+
67+
# - run: |
68+
# echo "Run, Build Application using script"
69+
# ./location_of_script_within_repo/buildscript.sh
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v2

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Tests
2+
on: [push, pull_request]
3+
env:
4+
CI: true
5+
NODE_COV: 20 # The Node.js version to run coverage on
6+
7+
jobs:
8+
run:
9+
name: Node ${{ matrix.node }} on ${{ matrix.os }}
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
node: [18, 20]
16+
os: [ubuntu-latest, windows-latest]
17+
18+
steps:
19+
- name: Clone repository
20+
uses: actions/checkout@v2
21+
22+
- name: Set Node.js version
23+
uses: actions/setup-node@v1
24+
with:
25+
node-version: ${{ matrix.node }}
26+
27+
- name: Install yarn dependencies
28+
run: yarn install
29+
30+
- name: Run Jest tests
31+
run: yarn test --runInBand
32+
if: "!(startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV)"
33+
34+
- name: Run Jest tests with coverage
35+
run: yarn test --runInBand --coverage
36+
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV
37+
38+
- name: Run Coveralls
39+
uses: coverallsapp/github-action@master
40+
if: startsWith(matrix.os, 'ubuntu') && matrix.node == env.NODE_COV
41+
with:
42+
github-token: "${{ secrets.GITHUB_TOKEN }}"
43+
path-to-lcov: "./.coverage/lcov.info"

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## v2.1.0
2+
3+
- Added: `ignoreRule` option
4+
- Updated: `css-to-react-native` dependency to v3.2.0
5+
6+
## v2.0.0
7+
8+
- Breaking: updated `css-to-react-native` dependency to v3.0.0. This version removes the support for line-height with multiplier, adds support for `place-content` CSS property, and more.
9+
- Breaking: updated `css` dependency to v3.0.0.
10+
111
## v1.9.0
212

313
- Added: Typescript type definitions.

README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# css-to-react-native-transform
22

33
[![NPM version](http://img.shields.io/npm/v/css-to-react-native-transform.svg)](https://www.npmjs.org/package/css-to-react-native-transform)
4-
[![Build Status](https://travis-ci.org/kristerkari/css-to-react-native-transform.svg?branch=master)](https://travis-ci.org/kristerkari/css-to-react-native-transform)
5-
[![Build status](https://ci.appveyor.com/api/projects/status/75s8ls2m47by8b1x/branch/master?svg=true)](https://ci.appveyor.com/project/kristerkari/css-to-react-native-transform/branch/master)
4+
[![Build Status](https://github.com/kristerkari/css-to-react-native-transform/workflows/Tests/badge.svg)](https://github.com/kristerkari/css-to-react-native-transform/actions?workflow=Tests)
65
[![Coverage Status](https://coveralls.io/repos/github/kristerkari/css-to-react-native-transform/badge.svg?branch=master)](https://coveralls.io/github/kristerkari/css-to-react-native-transform?branch=master)
76
[![Downloads per month](https://img.shields.io/npm/dm/css-to-react-native-transform.svg)](http://npmcharts.com/compare/css-to-react-native-transform)
87
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
9-
[![Greenkeeper badge](https://badges.greenkeeper.io/kristerkari/css-to-react-native-transform.svg)](https://greenkeeper.io/)
108

119
A lightweight wrapper on top of
1210
[css-to-react-native](https://github.com/styled-components/css-to-react-native)
@@ -71,6 +69,38 @@ transform(`
7169
}
7270
```
7371

72+
### `ignoreRule` option
73+
74+
```js
75+
transform(
76+
`
77+
.foo {
78+
color: red;
79+
}
80+
.bar {
81+
font-size: 12px;
82+
}
83+
`,
84+
{
85+
ignoreRule: selector => {
86+
if (selector === ".foo") {
87+
return true;
88+
}
89+
},
90+
},
91+
);
92+
```
93+
94+
↓ ↓ ↓ ↓ ↓ ↓
95+
96+
```js
97+
{
98+
bar: {
99+
fontSize: 12;
100+
}
101+
}
102+
```
103+
74104
### CSS Modules :export block
75105

76106
Parsing the [CSS Modules (ICSS) :export](https://github.com/css-modules/icss#export) is supported. The `:export` is often used to share variables from CSS or from a preprocessor like Sass/Less/Stylus to Javascript:

appveyor.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

index.d.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
export default function transform(css: string, options?: {
2-
parseMediaQueries?: boolean;
3-
}): { [selector: string]: unknown; };
1+
export default function transform(
2+
css: string,
3+
options?: {
4+
ignoreRule?: (selector: string) => boolean;
5+
parseMediaQueries?: boolean;
6+
},
7+
): { [selector: string]: unknown };

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@startupjs/css-to-react-native-transform",
33
"description": "Convert CSS text to a React Native stylesheet object",
4-
"version": "1.9.0-2",
4+
"version": "2.1.0-0",
55
"publishConfig": {
66
"access": "public"
77
},
@@ -14,19 +14,19 @@
1414
"build": "babel src --ignore *.spec.js --out-dir dist",
1515
"test": "jest --coverage",
1616
"prepublish": "npm run build",
17-
"release": "npmpub"
17+
"release": "np"
1818
},
1919
"devDependencies": {
20-
"@babel/cli": "^7.5.5",
21-
"@babel/core": "^7.5.5",
22-
"@babel/preset-env": "^7.5.5",
23-
"babel-jest": "^24.9.0",
20+
"@babel/cli": "^7.14.5",
21+
"@babel/core": "^7.14.6",
22+
"@babel/preset-env": "^7.14.7",
23+
"babel-jest": "^29.1.2",
2424
"coveralls": "^3.0.6",
25-
"husky": "^3.0.4",
26-
"jest": "^24.9.0",
27-
"lint-staged": "^9.2.4",
28-
"npmpub": "^4.1.0",
29-
"prettier": "^1.18.2"
25+
"husky": "^9.0.11",
26+
"jest": "^29.2.0",
27+
"lint-staged": "^15.2.2",
28+
"np": "^10.0.6",
29+
"prettier": "^3.0.0"
3030
},
3131
"jest": {
3232
"transform": {
@@ -60,9 +60,9 @@
6060
"trailingComma": "all"
6161
},
6262
"dependencies": {
63-
"css": "^2.2.4",
63+
"css": "^3.0.0",
6464
"css-mediaquery": "^0.1.2",
65-
"css-to-react-native": "^2.3.2"
65+
"css-to-react-native": "^3.2.0"
6666
},
6767
"repository": {
6868
"type": "git",

src/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ const transform = (css, options) => {
103103
if (
104104
rootRe.test(rule.selectors[s])
105105
? false
106-
: (
107-
rule.selectors[s].indexOf(".") !== 0 ||
106+
: rule.selectors[s].indexOf(".") !== 0 ||
108107
(rule.selectors[s].indexOf(":") !== -1 &&
109108
(options != null && options.parsePartSelectors
110109
? !cssPartRe.test(rule.selectors[s])
@@ -114,7 +113,13 @@ const transform = (css, options) => {
114113
rule.selectors[s].indexOf(">") !== -1 ||
115114
rule.selectors[s].indexOf("+") !== -1 ||
116115
rule.selectors[s].indexOf(" ") !== -1
117-
)
116+
) {
117+
continue;
118+
}
119+
120+
if (
121+
typeof options?.ignoreRule === "function" &&
122+
options.ignoreRule(rule.selectors[s]) === true
118123
) {
119124
continue;
120125
}
@@ -163,6 +168,13 @@ const transform = (css, options) => {
163168
for (const r in rule.rules) {
164169
const ruleRule = rule.rules[r];
165170
for (const s in ruleRule.selectors) {
171+
if (
172+
typeof options?.ignoreRule === "function" &&
173+
options.ignoreRule(ruleRule.selectors[s]) === true
174+
) {
175+
continue;
176+
}
177+
166178
result[media] = result[media] || {};
167179
const selector = ruleRule.selectors[s].replace(/^\./, "");
168180
const mediaStyles = (result[media][selector] =

0 commit comments

Comments
 (0)