This commit is contained in:
Max Shmelev 2020-04-16 20:26:18 -07:00
Коммит c9adb26f9c
13 изменённых файлов: 12610 добавлений и 0 удалений

16
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,16 @@
.cache/
coverage/
dist/*
!dist/index.html
node_modules/
*.log
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

34
README.md Normal file
Просмотреть файл

@ -0,0 +1,34 @@
# consent-banner
## Building and running on localhost
First install dependencies:
```sh
npm i
```
To create a production build:
```sh
npm run build-prod
```
To create a development build:
```sh
npm run build
```
## Running
```sh
node run start
```
## Testing
```sh
node run test
```

15
dist/index.html поставляемый Normal file
Просмотреть файл

@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<title>Test page</title>
<meta charset="utf-8">
</head>
<body>
<div id="app"></div>
<h1>aaabcdef</h1>
<script src="consent-banner.js"></script>
</body>
</html>

31
jest.config.js Normal file
Просмотреть файл

@ -0,0 +1,31 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html
module.exports = {
clearMocks: true,
collectCoverageFrom: [
"src/**/*.{js,jsx,ts,tsx}",
"!*.d.ts"
],
coverageReporters: [
"html"
],
moduleNameMapper: {
"^.+\\.(css|scss)$": "identity-obj-proxy"
},
resolver: "jest-pnp-resolver",
testMatch: [
"<rootDir>/src/**/*.test.ts?(x)"
],
testEnvironment: "jsdom",
testURL: "http://localhost",
transform: {
"^.+\\.tsx?$": "<rootDir>/node_modules/ts-jest",
},
transformIgnorePatterns: [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"
],
testPathIgnorePatterns: [
],
//testResultsProcessor: "<rootDir>/node_modules/jest-junit-reporter",
};

12273
package-lock.json сгенерированный Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

47
package.json Normal file
Просмотреть файл

@ -0,0 +1,47 @@
{
"name": "consent-banner",
"version": "2.0.0",
"description": "",
"main": "index.js",
"keywords": [],
"author": "Microsoft",
"license": "MIT",
"scripts": {
"build": "webpack -d --mode development",
"build-prod": "webpack -p --mode production",
"start": "webpack-dev-server --open",
"test": "jest --watchAll",
"test-coverage": "jest --coverage",
"test-ci": "jest",
"lint": "tslint -p tsconfig.json -t stylish"
},
"dependencies": {},
"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node-sass": "^4.11.0",
"awesome-typescript-loader": "^5.2.1",
"css-loader": "^3.5.2",
"identity-obj-proxy": "^3.0.0",
"jest": "^25.3.0",
"jest-junit-reporter": "^1.1.0",
"jest-pnp-resolver": "^1.2.1",
"node-sass": "^4.13.1",
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"sass-loader": "^8.0.2",
"style-loader": "^1.1.4",
"ts-jest": "^25.3.1",
"tslint": "^6.1.1",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3"
},
"browserslist": [
">0.2%",
"not ie <= 9",
"not dead",
"not op_mini all"
]
}

1
src/declarations.d.ts поставляемый Normal file
Просмотреть файл

@ -0,0 +1 @@
declare module "*.scss";

5
src/index.test.ts Normal file
Просмотреть файл

@ -0,0 +1,5 @@
import * as ind from "./index";
test("adds 1 + 2 to equal 3", () => {
expect(1 + 2).toBe(3);
});

3
src/index.ts Normal file
Просмотреть файл

@ -0,0 +1,3 @@
import "./styles.scss";
console.log("aabcd");

7
src/styles.scss Normal file
Просмотреть файл

@ -0,0 +1,7 @@
$primary-color: white;
$bg: black;
h1 {
color: $primary-color;
background-color: $bg;
color: rebeccapurple;
}

16
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,16 @@
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"noImplicitAny": true,
"module": "esnext",
"moduleResolution": "node",
"target": "es5",
"allowJs": true,
},
"include": [
"./src/**/*"
]
}

75
tslint.json Normal file
Просмотреть файл

@ -0,0 +1,75 @@
{
"extends": ["tslint-microsoft-contrib"],
"rules": {
// coding style
"align": [true, "elements", "members", "statements"],
"ban-types": [true, ["Object", "Strong typing preferred"], ["AnyAction"]],
"function-name": [true, {
"static-method-regex": "^[a-z][\\w\\d]+$"
}],
"quotemark": [true, "double"],
"linebreak-style": false,
"max-func-body-length": false,
"max-line-length": false,
"member-ordering": [true, {"order": [
"public-static-field",
"public-instance-field",
"protected-static-field",
"protected-instance-field",
"private-static-field",
"private-instance-field",
"public-constructor",
"protected-constructor",
"private-constructor",
"public-static-method",
"public-instance-method",
"protected-static-method",
"private-static-method",
"protected-instance-method",
"private-instance-method"
] }],
"newline-before-return": false,
"newline-per-chained-call": false,
"no-consecutive-blank-lines": [true, 2],
"typedef": [true, "parameter", "property-declaration", "member-variable-declaration", "array-destructuring"],
"variable-name": [true, "allow-pascal-case", "ban-keywords"],
// modules
"export-name": false,
"import-name": false,
"no-submodule-imports": false,
"no-relative-imports": false,
"no-default-export": false,
"no-import-side-effect": [true, {"ignore-module": "(\\.png|\\.jpg|\\.svg|\\.css|\\.scss)$"}],
"no-implicit-dependencies": [true, "dev"],
"ordered-imports": false,
// documentation
"completed-docs": false,
"missing-jsdoc": false,
// best practices
"no-floating-promises": true,
"no-increment-decrement": false,
"no-null-keyword": false,
"no-parameter-reassignment": false,
"no-unsafe-any": false,
"no-unused-expression": [true, "allow-fast-null-checks", "allow-new"],
"no-void-expression": [true, "ignore-arrow-function-shorthand"],
"jsx-no-lambda": false,
"jsx-no-multiline-js": false,
"strict-boolean-expressions": false,
"underscore-consistent-invocation": false,
"use-simple-attributes": false,
"no-console": false,
// tests
"mocha-no-side-effect-code": false
},
"linterOptions": {
"exclude": [
"*.js",
"node_modules/**/*.ts"
]
}
}

87
webpack.config.js Normal file
Просмотреть файл

@ -0,0 +1,87 @@
const webpack = require("webpack");
const path = require("path");
const config = {
entry: "./src/index.ts",
output: {
path: path.resolve(__dirname, "dist"),
filename: "consent-banner.js"
},
module: {
rules: [
{
test: /\.css$/,
exclude: /\.module\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
modules: true
}
},
{
loader: "postcss-loader", options: {
ident: "postcss",
plugins: () => [
postcssPresetEnv({
autoprefixer: {
flexbox: "no-2009",
},
stage: 2,
})
]
}
}
],
},
{
test: /\.scss$/,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
modules: true
}
},
{
loader: "postcss-loader", options: {
ident: "postcss",
plugins: () => [
require("postcss-preset-env")({
autoprefixer: {
flexbox: "no-2009",
},
stage: 2
})
]
}
},
"sass-loader"
]
},
{
test: /\.ts(x)?$/,
exclude: /node_modules/,
use: [
"awesome-typescript-loader"
]
}
]
},
resolve: {
extensions: [
".ts",
".js"
]
},
devServer: {
contentBase: "./dist",
watchContentBase: true
}
};
module.exports = config;