22 | )
23 | }),
24 | "/textstat-rule-document-dependency": createPage({
25 | title: "textstat-rule-document-dependency",
26 | getContent: () => import("./textstat-rule-document-dependency")
27 | }),
28 | "/textstat-rule-number-of-characters": createPage({
29 | title: "textstat-rule-number-of-characters",
30 | getContent: () => import("./textstat-rule-number-of-characters")
31 | })
32 | }
33 | });
34 |
--------------------------------------------------------------------------------
/packages/@textstat/textstat-rule-preset-standard/src/textstat-rule-preset-standard.ts:
--------------------------------------------------------------------------------
1 | export function createPreset(_options = {}) {
2 | return {
3 | rules: {
4 | "textstat-rule-filesize": require("@textstat/textstat-rule-filesize"),
5 | "textstat-rule-document-dependency": require("@textstat/textstat-rule-document-dependency"),
6 | "textstat-rule-number-of-characters": require("@textstat/textstat-rule-number-of-characters"),
7 | "textstat-rule-number-of-images": require("@textstat/textstat-rule-number-of-images"),
8 | "textstat-rule-number-of-links": require("@textstat/textstat-rule-number-of-links"),
9 | "textstat-rule-number-of-list-items": require("@textstat/textstat-rule-number-of-list-items"),
10 | "textstat-rule-number-of-paragraphs": require("@textstat/textstat-rule-number-of-paragraphs"),
11 | "textstat-rule-number-of-sentences": require("@textstat/textstat-rule-number-of-sentences")
12 | },
13 | rulesConfig: {
14 | "textstat-rule-filesize": true,
15 | "textstat-rule-document-dependency": true,
16 | "textstat-rule-number-of-characters": true,
17 | "textstat-rule-number-of-images": true,
18 | "textstat-rule-number-of-links": true,
19 | "textstat-rule-number-of-list-items": true,
20 | "textstat-rule-number-of-paragraphs": true,
21 | "textstat-rule-number-of-sentences": true
22 | }
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/tools/add-new-rule.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # variable
3 | declare scriptDir=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
4 | declare currentDir=$(pwd)
5 | declare dirName=$(basename "${currentDir}")
6 | declare currentDirName=$(basename "${currentDir}")
7 |
8 | # dependecy script
9 | # https://github.com/zeke/npe
10 | if !type npe >/dev/null 2>&1; then
11 | npm install npe --global
12 | fi
13 | sh ${scriptDir}/node.js.sh
14 |
15 | function echo_message(){
16 | echo "\033[31m=>\033[0m \033[036m$1\033[0m"
17 | }
18 | # Install
19 | echo_message "npm install"
20 | yarn add --dev --pure-lockfile \
21 | typescript \
22 | mocha \
23 | @types/node \
24 | @types/mocha \
25 | cross-env \
26 | ts-node
27 |
28 | sh ${scriptDir}/add-prettier.sh
29 |
30 | # Copy config
31 | echo_message "Copy .tsconfig.json"
32 | cp ${scriptDir}/resources/tsconfig.json ./
33 | cp ${scriptDir}/resources/test.tsconfig.json ./test/tsconfig.json
34 | cp ${scriptDir}/resources/typescript.mocha.opts ./test/mocha.opts
35 | # Edit package.json
36 | ## Add script
37 | echo_message "Add npm run-script"
38 | npe scripts.build "cross-env NODE_ENV=production tsc --build"
39 | npe scripts.watch "tsc --build --watch"
40 | npe scripts.prepublish "npm run --if-present build"
41 | npe scripts.test "mocha \"test/**/*.ts\""
42 | npe main "lib/${currentDirName}/src/index.js"
43 | npe types "lib/${currentDirName}/src/index.d.ts"
44 | sort-package-json
45 | # create README
46 | rm README.md
47 | pkg-to-readme --template "${scriptDir}/resources/textstat.readme.template" -o ./README.md
48 | # git
49 | git add .
50 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "azu",
3 | "license": "MIT",
4 | "name": "textstat",
5 | "version": "1.0.0",
6 | "description": "textstat analyze text and summarize data.",
7 | "scripts": {
8 | "clean": "lerna run clean && lerna clean --yes",
9 | "test": "lerna run test",
10 | "updateSnapshot": "UPDATE_SNAPSHOT=1 lerna run test",
11 | "build": "lerna run build --ignore @textstat/textstat-view",
12 | "netlify": "lerna run build --scope @textstat/textstat-view",
13 | "bootstrap": "lerna bootstrap && yarn run build",
14 | "publish": "lerna publish --conventional-commits",
15 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\""
16 | },
17 | "keywords": [
18 | "textlint",
19 | "textstat"
20 | ],
21 | "private": true,
22 | "devDependencies": {
23 | "husky": "^1.3.1",
24 | "lerna": "^3.13.1",
25 | "lint-staged": "^8.1.4",
26 | "prettier": "^1.16.4"
27 | },
28 | "prettier": {
29 | "printWidth": 120,
30 | "tabWidth": 4
31 | },
32 | "lint-staged": {
33 | "*.{js,jsx,ts,tsx,css}": [
34 | "prettier --write",
35 | "git add"
36 | ]
37 | },
38 | "workspaces": {
39 | "packages": [
40 | "packages/*",
41 | "packages/@textstat/*"
42 | ],
43 | "nohoist": [
44 | "**/@types/mocha",
45 | "**/@types/mocha/**",
46 | "**/@types/jest",
47 | "**/@types/jest/**"
48 | ]
49 | },
50 | "husky": {
51 | "hooks": {
52 | "post-commit": "git reset",
53 | "pre-commit": "lint-staged"
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/packages/@textstat/textstat-view/src/pages/textstat-rule-document-dependency.tsx:
--------------------------------------------------------------------------------
1 | import * as React from "react";
2 | import { StatContext } from "../context/StatContext";
3 | import { DocumentDependencyView } from "../components/DocumentDependencyView/DocumentDependencyView";
4 |
5 | export class TextstatRuleDocumentDependency extends React.Component {
6 | state = {
7 | reverse: false
8 | };
9 |
10 | private onChangeCheckbox = () => {
11 | this.setState({
12 | reverse: !this.state.reverse
13 | });
14 | };
15 |
16 | render() {
17 | return (
18 |