-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ESLint * Refactor "Synchronize" code with ESLint * refactor rollup config formatting * convert config files to js
- Loading branch information
1 parent
b2a8559
commit 3bb7dae
Showing
21 changed files
with
5,139 additions
and
4,087 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,2 @@ | ||
node_modules | ||
dist |
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,31 @@ | ||
module.exports = { | ||
plugins: ["prettier", "import"], | ||
extends: ["airbnb-base", "prettier", "plugin:import/recommended"], | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
rules: { | ||
"prettier/prettier": "error", | ||
"max-len": [ | ||
"error", | ||
{ | ||
code: 120, | ||
comments: 120, | ||
tabWidth: 4, | ||
ignoreUrls: false, | ||
ignoreTrailingComments: false, | ||
ignoreComments: false, | ||
}, | ||
], | ||
indent: [ | ||
"error", | ||
4, | ||
{ | ||
SwitchCase: 1, | ||
}, | ||
], | ||
"import/extensions": 0, | ||
"import/no-extraneous-dependencies": 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
yarn lint | ||
yarn test |
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
module.exports = { | ||
tabWidth: 4, | ||
endOfLine: "lf", | ||
printWidth: 120, | ||
singleQuote: 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
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 |
---|---|---|
@@ -1,91 +1,112 @@ | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import externals from "rollup-plugin-node-externals"; | ||
import alias from "@rollup/plugin-alias"; | ||
import { getBabelOutputPlugin } from "@rollup/plugin-babel"; | ||
import terser from "@rollup/plugin-terser"; | ||
import json from "@rollup/plugin-json"; | ||
|
||
// CommonJS build | ||
const cjs = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: `./dist/ecsstree.cjs`, | ||
format: "cjs", | ||
exports: "auto", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: [json(), externals(), commonjs({ sourceMap: false }), resolve({ preferBuiltins: false })], | ||
}; | ||
|
||
// ECMAScript build | ||
const esm = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: `./dist/ecsstree.esm.js`, | ||
format: "esm", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: [json(), externals(), commonjs({ sourceMap: false }), resolve({ preferBuiltins: false })], | ||
}; | ||
|
||
const browserPlugins = [ | ||
json(), | ||
commonjs({ sourceMap: false }), | ||
resolve({ preferBuiltins: false, browser: true }), | ||
alias({ | ||
entries: [ | ||
{ | ||
find: "css-tree", | ||
replacement: "node_modules/css-tree/dist/csstree.esm.js", | ||
}, | ||
], | ||
}), | ||
getBabelOutputPlugin({ | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: ["> 1%", "not dead"], | ||
}, | ||
], | ||
], | ||
allowAllFormats: true, | ||
}), | ||
terser(), | ||
]; | ||
|
||
// Browser-friendly UMD build | ||
const umd = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: `./dist/ecsstree.umd.min.js`, | ||
name: "ECSSTree", | ||
format: "umd", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: browserPlugins, | ||
}; | ||
|
||
// Browser-friendly IIFE build | ||
const iife = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: `./dist/ecsstree.iife.min.js`, | ||
name: "ECSSTree", | ||
format: "iife", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: browserPlugins, | ||
}; | ||
|
||
// Export build configs for Rollup | ||
export default [cjs, esm, umd, iife]; | ||
/* eslint-disable prettier/prettier */ | ||
import alias from "@rollup/plugin-alias"; | ||
import commonjs from "@rollup/plugin-commonjs"; | ||
import externals from "rollup-plugin-node-externals"; | ||
import json from "@rollup/plugin-json"; | ||
import resolve from "@rollup/plugin-node-resolve"; | ||
import terser from "@rollup/plugin-terser"; | ||
import { getBabelOutputPlugin } from "@rollup/plugin-babel"; | ||
|
||
const commonPlugins = [ | ||
json(), | ||
commonjs({ sourceMap: false }), | ||
]; | ||
|
||
// CommonJS build | ||
const cjs = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: "./dist/ecsstree.cjs", | ||
format: "cjs", | ||
exports: "auto", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: [ | ||
...commonPlugins, | ||
externals(), | ||
resolve({ preferBuiltins: false }) | ||
], | ||
}; | ||
|
||
// ECMAScript build | ||
const esm = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: "./dist/ecsstree.esm.js", | ||
format: "esm", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: [ | ||
...commonPlugins, | ||
externals(), | ||
resolve({ preferBuiltins: false }), | ||
], | ||
}; | ||
|
||
const browserPlugins = [ | ||
...commonPlugins, | ||
resolve({ | ||
preferBuiltins: false, | ||
browser: true | ||
}), | ||
alias({ | ||
entries: [ | ||
{ | ||
find: "css-tree", | ||
replacement: "node_modules/css-tree/dist/csstree.esm.js", | ||
}, | ||
], | ||
}), | ||
getBabelOutputPlugin({ | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: ["> 1%", "not dead"], | ||
}, | ||
], | ||
], | ||
allowAllFormats: true, | ||
}), | ||
terser(), | ||
]; | ||
|
||
// Browser-friendly UMD build | ||
const umd = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: "./dist/ecsstree.umd.min.js", | ||
name: "ECSSTree", | ||
format: "umd", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: browserPlugins, | ||
}; | ||
|
||
// Browser-friendly IIFE build | ||
const iife = { | ||
input: "./src/index.js", | ||
output: [ | ||
{ | ||
file: "./dist/ecsstree.iife.min.js", | ||
name: "ECSSTree", | ||
format: "iife", | ||
sourcemap: false, | ||
}, | ||
], | ||
plugins: browserPlugins, | ||
}; | ||
|
||
// Export build configs for Rollup | ||
export default [ | ||
cjs, | ||
esm, | ||
umd, | ||
iife | ||
]; |
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 |
---|---|---|
@@ -1,40 +1,40 @@ | ||
import syntax from "./syntax/index.js"; | ||
|
||
// Fork API doesn't export everything, so we need to export the rest of | ||
// the API manually. See the original source code: | ||
// https://github.com/csstree/csstree/blob/master/lib/index.js | ||
|
||
export * from "./version.js"; | ||
|
||
export { | ||
createSyntax, | ||
List, | ||
Lexer, | ||
tokenTypes, | ||
tokenNames, | ||
TokenStream, | ||
definitionSyntax, | ||
clone, | ||
ident, | ||
string, | ||
url, | ||
} from "css-tree"; | ||
|
||
// Export the forked syntax (comes from the Fork API) | ||
export const { | ||
tokenize, | ||
parse, | ||
generate, | ||
lexer, | ||
createLexer, | ||
|
||
walk, | ||
find, | ||
findLast, | ||
findAll, | ||
|
||
toPlainObject, | ||
fromPlainObject, | ||
|
||
fork, | ||
} = syntax; | ||
import syntax from "./syntax/index.js"; | ||
|
||
// Fork API doesn't export everything, so we need to export the rest of | ||
// the API manually. See the original source code: | ||
// https://github.com/csstree/csstree/blob/master/lib/index.js | ||
|
||
export { default as version } from "./version.js"; | ||
|
||
export { | ||
createSyntax, | ||
List, | ||
Lexer, | ||
tokenTypes, | ||
tokenNames, | ||
TokenStream, | ||
definitionSyntax, | ||
clone, | ||
ident, | ||
string, | ||
url, | ||
} from "css-tree"; | ||
|
||
// Export the forked syntax (comes from the Fork API) | ||
export const { | ||
tokenize, | ||
parse, | ||
generate, | ||
lexer, | ||
createLexer, | ||
|
||
walk, | ||
find, | ||
findLast, | ||
findAll, | ||
|
||
toPlainObject, | ||
fromPlainObject, | ||
|
||
fork, | ||
} = syntax; |
Oops, something went wrong.