-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf8f5b5
Showing
18 changed files
with
996 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"root": true, | ||
"extends": [ | ||
"eslint-config-niksy", | ||
"eslint-config-niksy/next", | ||
"eslint-config-prettier" | ||
], | ||
"plugins": ["eslint-plugin-prettier"], | ||
"rules": { | ||
"prettier/prettier": 1 | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["rollup.config.js"], | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "script" | ||
}, | ||
"plugins": ["eslint-plugin-unicorn"], | ||
"rules": { | ||
"no-console": 0, | ||
"unicorn/numeric-separators-style": 0 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
node_modules/ | ||
package-lock.json | ||
yarn.lock | ||
npm-debug.log | ||
cjs/ | ||
esm/ | ||
!test/fixtures/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"*.js": ["eslint --fix"], | ||
"*.(md|json)": ["prettier --ignore-path .gitignore --write"], | ||
".!(npm)*rc": ["prettier --ignore-path .gitignore --parser json --write"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 4, | ||
"useTabs": true, | ||
"semi": true, | ||
"singleQuote": true, | ||
"quoteProps": "preserve", | ||
"jsxSingleQuote": true, | ||
"trailingComma": "none", | ||
"bracketSpacing": true, | ||
"jsxBracketSameLine": false, | ||
"arrowParens": "always", | ||
"requirePragma": false, | ||
"insertPragma": false, | ||
"proseWrap": "always", | ||
"htmlWhitespaceSensitivity": "css", | ||
"vueIndentScriptAndStyle": false, | ||
"endOfLine": "lf", | ||
"embeddedLanguageFormatting": "auto", | ||
"overrides": [ | ||
{ | ||
"files": "package.json", | ||
"options": { | ||
"useTabs": false, | ||
"tabWidth": 2 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- '10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## [Unreleased][] | ||
|
||
### Added | ||
|
||
- Initial implementation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) Ivan Nikolić <http://ivannikolic.com> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# css-functions-list | ||
|
||
[![Build Status][ci-img]][ci] | ||
|
||
List of standard and | ||
[browser specific](<(https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix)>) | ||
CSS functions. | ||
|
||
Source of data is MDN reference on | ||
[CSS functions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Functions) | ||
and | ||
[general CSS features](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference). | ||
|
||
## Install | ||
|
||
```sh | ||
npm install css-functions-list --save | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { promises as fs } from 'fs'; | ||
import functionsListPath from 'css-functions-list'; | ||
|
||
(async () => { | ||
const functionsList = JSON.parse( | ||
await fs.readFile(functionsListPath, 'utf8') | ||
); | ||
console.log(functionsList); | ||
/* [ | ||
'abs', | ||
'acos', | ||
'annotation', | ||
'asin', | ||
'atan', | ||
'atan2', | ||
'attr', | ||
'blur', | ||
'brightness', | ||
'calc' | ||
// … | ||
]; */ | ||
})(); | ||
``` | ||
|
||
## API | ||
|
||
### functionsListPath | ||
|
||
Type: `string` | ||
|
||
Path to CSS functions list JSON file. | ||
|
||
## License | ||
|
||
MIT © [Ivan Nikolić](http://ivannikolic.com) | ||
|
||
<!-- prettier-ignore-start --> | ||
|
||
[ci]: https://travis-ci.com/niksy/css-functions-list | ||
[ci-img]: https://travis-ci.com/niksy/css-functions-list.svg?branch=master | ||
|
||
<!-- prettier-ignore-end --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import path from 'path'; | ||
import fetch from 'isomorphic-unfetch'; | ||
import { JSDOM } from 'jsdom'; | ||
import writeJsonFile from 'write-json-file'; | ||
|
||
const references = [ | ||
{ | ||
url: 'https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix', | ||
transform: (document) => { | ||
let list = document.querySelectorAll('#css_prefixes + div li code'); | ||
list = [...list].map((node) => node.textContent); | ||
return list; | ||
} | ||
}, | ||
{ | ||
url: 'https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Functions', | ||
transform: (document) => { | ||
let list = document.querySelectorAll('.main-page-content dt code'); | ||
list = [...list] | ||
.map((node) => node.textContent) | ||
.map((name) => name.replace('()', '')); | ||
return list; | ||
} | ||
}, | ||
{ | ||
url: 'https://developer.mozilla.org/en-US/docs/Web/CSS/Reference', | ||
transform: (document) => { | ||
let list = document.querySelectorAll('#index + div .index li code'); | ||
list = [...list] | ||
.map((node) => node.textContent) | ||
.filter((name) => /^[^:]\S+\(\)$/.test(name)) | ||
.map((name) => name.replace('()', '')); | ||
return list; | ||
} | ||
} | ||
]; | ||
|
||
async function main() { | ||
const responses = await Promise.all( | ||
references.map(({ url }) => fetch(url)) | ||
); | ||
const markups = await Promise.all( | ||
responses.map((response) => response.text()) | ||
); | ||
const [prefixes, ...functions] = markups.map((markup, index) => { | ||
const { | ||
window: { document } | ||
} = new JSDOM(markup); | ||
return references[index].transform(document); | ||
}); | ||
let results = [...new Set([].concat(...functions))].sort(); | ||
results = [ | ||
...results, | ||
...prefixes.map((prefix) => results.map((name) => `${prefix}${name}`)) | ||
]; | ||
results = [].concat(...results); | ||
const filename = new URL('index.json', import.meta.url).pathname; | ||
await writeJsonFile(filename, results); | ||
console.log('Done!'); | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const location = new URL('index.json', import.meta.url).pathname; | ||
|
||
export default location; |
Oops, something went wrong.