├── .githooks └── pre-commit ├── .github ├── release.yml └── workflows │ ├── codeql-analysis.yml │ └── test.yml ├── .gitignore ├── .node-version ├── .prettierignore ├── .yarnrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs ├── create-textlint-worker.md └── resources │ └── textlint_editor.png ├── lerna.json ├── netlify.toml ├── nx.json ├── package.json ├── packages ├── @textlint │ ├── config-inliner │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ ├── config-inliner.ts │ │ │ └── rules │ │ │ │ └── prh.ts │ │ ├── test │ │ │ ├── fixtures │ │ │ │ └── prh │ │ │ │ │ └── prh.yml │ │ │ ├── prh.test.ts │ │ │ └── tsconfig.json │ │ ├── tsconfig.json │ │ └── tsconfig.module.json │ ├── config-partial-parser │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ ├── TextlintConfigDescriptor.ts │ │ │ ├── TextlintRcConfig.ts │ │ │ ├── config-util.ts │ │ │ ├── index.ts │ │ │ └── parser.ts │ │ ├── test │ │ │ ├── index.test.ts │ │ │ ├── modules_fixtures │ │ │ │ ├── textlint-rule-a │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── textlint-rule-b │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── textlint-rule-c-sub1 │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ ├── textlint-rule-c-sub2 │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ │ └── textlint-rule-preset-c │ │ │ │ │ ├── index.js │ │ │ │ │ └── package.json │ │ │ ├── snapshots │ │ │ │ ├── plguin │ │ │ │ │ ├── input.json │ │ │ │ │ └── output.json │ │ │ │ └── rules │ │ │ │ │ ├── input.json │ │ │ │ │ └── output.json │ │ │ └── tsconfig.json │ │ ├── tsconfig.json │ │ └── tsconfig.module.json │ ├── runtime-helper │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ ├── index.ts │ │ │ ├── preset-to-rule.ts │ │ │ └── worker-cache.ts │ │ ├── test │ │ │ └── tsconfig.json │ │ ├── tsconfig.json │ │ └── tsconfig.module.json │ ├── script-compiler │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── .textlintrc.json │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bin │ │ │ └── cmd.js │ │ ├── example │ │ │ ├── index.html │ │ │ ├── load-meta.js │ │ │ └── webindex.html │ │ ├── package.json │ │ ├── patch │ │ │ ├── README.md │ │ │ └── kuromoji.js │ │ ├── prh.yml │ │ ├── src │ │ │ ├── CodeGenerator │ │ │ │ ├── API.ts │ │ │ │ ├── CodeGeneraterOptions.ts │ │ │ │ └── worker-codegen.ts │ │ │ ├── cli.ts │ │ │ ├── compiler.ts │ │ │ └── index.ts │ │ ├── test │ │ │ └── tsconfig.json │ │ ├── tsconfig.json │ │ └── tsconfig.module.json │ ├── script-parser │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── package.json │ │ ├── src │ │ │ └── script-parser.ts │ │ ├── test │ │ │ ├── script-parser.test.ts │ │ │ └── tsconfig.json │ │ ├── tsconfig.json │ │ └── tsconfig.module.json │ └── website-generator │ │ ├── .gitignore │ │ ├── .mocharc.json │ │ ├── .prettierignore │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bin │ │ └── cmd.js │ │ ├── package.json │ │ ├── src │ │ ├── cli.ts │ │ ├── index.ts │ │ └── website-generator.ts │ │ ├── template │ │ └── README.md │ │ ├── test │ │ └── tsconfig.json │ │ ├── tools │ │ └── website-generator.mjs │ │ ├── tsconfig.json │ │ └── tsconfig.module.json ├── textchecker-element │ ├── .babelrc │ ├── .gitignore │ ├── .mocharc.json │ ├── .prettierignore │ ├── .textlintrc.json │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── index.html │ ├── index.ts │ ├── package.json │ ├── src │ │ ├── attach-to-text-area.ts │ │ ├── icon-fixit.svg │ │ ├── icon-textlint.svg │ │ ├── icon-trash.svg │ │ ├── index.ts │ │ ├── text-checker-element.ts │ │ ├── text-checker-popup-element.ts │ │ ├── text-checker-store.ts │ │ └── util │ │ │ ├── logger.ts │ │ │ ├── text-caret-pos.d.ts │ │ │ └── text-caret-pos.js │ ├── test │ │ └── tsconfig.json │ ├── tsconfig.json │ ├── tsconfig.module.json │ ├── vite.config.js │ └── vite.lib.config.js └── webextension │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── app │ ├── _locales │ │ └── en │ │ │ └── messages.json │ ├── images │ │ ├── Makefile │ │ ├── icon-128.png │ │ ├── icon-16.png │ │ ├── icon-19.png │ │ ├── icon-256.png │ │ ├── icon-38.png │ │ ├── icon-48.png │ │ └── textlint-icon_256x256.png │ ├── manifest.json │ ├── pages │ │ ├── edit-script.html │ │ ├── install-dialog.html │ │ └── popup.html │ ├── scripts │ │ ├── InstalledApp │ │ │ ├── StateContext.tsx │ │ │ ├── component │ │ │ │ ├── InstalledTextlintList.tsx │ │ │ │ └── TextlintrcEditor.tsx │ │ │ └── pages │ │ │ │ ├── EditPage.css │ │ │ │ ├── EditPage.tsx │ │ │ │ └── InstalledAppPage.tsx │ │ ├── background.ts │ │ ├── background │ │ │ ├── database.ts │ │ │ ├── onTextlintWorker.ts │ │ │ ├── scriptWorkerSet.ts │ │ │ └── textlint.ts │ │ ├── contentScript.ts │ │ ├── edit-script.tsx │ │ ├── install-dialog.tsx │ │ ├── pageScript.ts │ │ ├── popup.tsx │ │ ├── shared │ │ │ └── page-contents-shared.ts │ │ └── utils │ │ │ └── logger.ts │ └── styles │ │ └── popup.css │ ├── package.json │ ├── promo │ ├── Chrome-Webstore-Icon_128x128.png │ ├── Promo-Image-Large_920x680.png │ ├── Promo-Image-Marquee_1400x560.png │ ├── Promo-Image-Small_440x280.png │ ├── Screenshot_1280x800.png │ └── Screenshot_640x400.png │ ├── tools │ └── sync-version.js │ ├── tsconfig.json │ └── webextension-toolbox.config.js └── yarn.lock /.githooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | npx --no-install lint-staged 3 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | labels: 4 | - 'Type: Meta' 5 | - 'Type: Question' 6 | - 'Type: Release' 7 | 8 | categories: 9 | - title: Security Fixes 10 | labels: ['Type: Security'] 11 | - title: Breaking Changes 12 | labels: ['Type: Breaking Change'] 13 | - title: Features 14 | labels: ['Type: Feature'] 15 | - title: Bug Fixes 16 | labels: ['Type: Bug'] 17 | - title: Documentation 18 | labels: ['Type: Documentation'] 19 | - title: Refactoring 20 | labels: ['Type: Refactoring'] 21 | - title: Testing 22 | labels: ['Type: Testing'] 23 | - title: Maintenance 24 | labels: ['Type: Maintenance'] 25 | - title: CI 26 | labels: ['Type: CI'] 27 | - title: Dependency Updates 28 | labels: ['Type: Dependencies', "dependencies"] 29 | - title: Other Changes 30 | labels: ['*'] 31 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [ master ] 9 | schedule: 10 | - cron: '42 17 * * 2' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | permissions: 17 | actions: read 18 | contents: read 19 | security-events: write 20 | 21 | strategy: 22 | fail-fast: false 23 | matrix: 24 | language: [ 'javascript' ] 25 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 26 | # Learn more: 27 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 28 | 29 | steps: 30 | - name: Checkout repository 31 | uses: actions/checkout@v2 32 | 33 | # Initializes the CodeQL tools for scanning. 34 | - name: Initialize CodeQL 35 | uses: github/codeql-action/init@v1 36 | with: 37 | languages: ${{ matrix.language }} 38 | # If you wish to specify custom queries, you can do so here or in a config file. 39 | # By default, queries listed here will override any specified in a config file. 40 | # Prefix the list here with "+" to use these queries and those in the config file. 41 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 42 | 43 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 44 | # If this step fails, then you should remove it and run the build manually (see below) 45 | - name: Autobuild 46 | uses: github/codeql-action/autobuild@v1 47 | 48 | # ℹ️ Command-line programs to run using the OS shell. 49 | # 📚 https://git.io/JvXDl 50 | 51 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 52 | # and modify them (or add more) to build your code if your project 53 | # uses a compiled language 54 | 55 | #- run: | 56 | # make bootstrap 57 | # make release 58 | 59 | - name: Perform CodeQL Analysis 60 | uses: github/codeql-action/analyze@v1 61 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | on: [ push, pull_request ] 3 | env: 4 | CI: true 5 | permissions: 6 | contents: read 7 | jobs: 8 | test: 9 | name: "Test on Node.js ${{ matrix.node-version }} x ${{ matrix.os }}" 10 | runs-on: ${{ matrix.os }} 11 | strategy: 12 | matrix: 13 | node-version: [ 18, 20, 22 ] 14 | os: [ ubuntu-latest, windows-latest ] 15 | steps: 16 | - name: checkout 17 | uses: actions/checkout@v4 18 | - name: setup Node.js ${{ matrix.node-version }} 19 | uses: actions/setup-node@v4 20 | with: 21 | cache: "yarn" 22 | node-version: ${{ matrix.node-version }} 23 | - name: Install 24 | run: yarn install 25 | - name: Test 26 | run: yarn test 27 | - name: Build webextension (Chrome) 28 | run: npm run dist chrome 29 | if: matrix.os == 'ubuntu-latest' 30 | working-directory: packages/webextension 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | .env.test 62 | 63 | # parcel-bundler cache (https://parceljs.org/) 64 | .cache 65 | 66 | # next.js build output 67 | .next 68 | 69 | # nuxt.js build output 70 | .nuxt 71 | 72 | # vuepress build output 73 | .vuepress/dist 74 | 75 | # Serverless directories 76 | .serverless/ 77 | 78 | # FuseBox cache 79 | .fusebox/ 80 | 81 | # DynamoDB Local files 82 | .dynamodb/ 83 | 84 | 85 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 86 | 87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 88 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 89 | 90 | # User-specific stuff 91 | .idea/**/workspace.xml 92 | .idea/**/tasks.xml 93 | .idea/**/usage.statistics.xml 94 | .idea/**/dictionaries 95 | .idea/**/shelf 96 | 97 | # Generated files 98 | .idea/**/contentModel.xml 99 | 100 | # Sensitive or high-churn files 101 | .idea/**/dataSources/ 102 | .idea/**/dataSources.ids 103 | .idea/**/dataSources.local.xml 104 | .idea/**/sqlDataSources.xml 105 | .idea/**/dynamic.xml 106 | .idea/**/uiDesigner.xml 107 | .idea/**/dbnavigator.xml 108 | 109 | # Gradle 110 | .idea/**/gradle.xml 111 | .idea/**/libraries 112 | 113 | # Gradle and Maven with auto-import 114 | # When using Gradle or Maven with auto-import, you should exclude module files, 115 | # since they will be recreated, and may cause churn. Uncomment if using 116 | # auto-import. 117 | # .idea/modules.xml 118 | # .idea/*.iml 119 | # .idea/modules 120 | 121 | # CMake 122 | cmake-build-*/ 123 | 124 | # Mongo Explorer plugin 125 | .idea/**/mongoSettings.xml 126 | 127 | # File-based project format 128 | *.iws 129 | 130 | # IntelliJ 131 | out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Cursive Clojure plugin 140 | .idea/replstate.xml 141 | 142 | # Crashlytics plugin (for Android Studio and IntelliJ) 143 | com_crashlytics_export_strings.xml 144 | crashlytics.properties 145 | crashlytics-build.properties 146 | fabric.properties 147 | 148 | # Editor-based Rest Client 149 | .idea/httpRequests 150 | 151 | # Android studio 3.1+ serialized cache file 152 | .idea/caches/build_file_checksums.ser 153 | 154 | 155 | # Build files 156 | /lib 157 | /module 158 | 159 | # Local Netlify folder 160 | .netlify 161 | !/packages/webextension/app/dl/ 162 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | 20.8.1 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .yarn 2 | build/ 3 | dist/ 4 | download/ 5 | lib/ 6 | module/ 7 | example/ -------------------------------------------------------------------------------- /.yarnrc: -------------------------------------------------------------------------------- 1 | network-timeout 600000 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @textlint/editor 2 | 3 | textlint editor is privacy first linting tool on your browser. 4 | 5 | ## Usage 6 | 7 | 1. Install Web Extensions 8 | - [x] Chrome: 9 | - [x] ~Firefox: ~ See [#61](https://github.com/textlint/editor/issues/61) 10 | 2. Install your favorites textlint worker scripts 11 | - Example textlint worker scripts: 12 | - 13 | - 14 | - 15 | 3. Finally, you can linting any supported textarea with your textlint worker script 16 | 17 | :memo: @textlint/editor web extension hook the access of `https://*/*/textlint-worker.js`. If you navigate 18 | to `https://*/*/textlint-worker.js`, the web extension open installation dialog like Greasemonkey Extension. 19 | 20 | :memo: You want to use your customized rule, please use . 21 | 22 | ## Supports textarea 23 | 24 | - [x] textarea 25 | - [ ] contenteditable 26 | - [ ] Google Docs 27 | - [ ] Twitter 28 | - [ ] Medium 29 | - [ ] Wordpress 30 | - [ ] CodeMirror 31 | - [ ] ACE 32 | 33 | If you want to support new textarea, please create an issues or pull request 34 | to [textchecker-element](./packages/textchecker-element). 35 | 36 | ## Purpose 37 | 38 | - Privacy first 39 | - Offline works 40 | - Create own textlint that is bundled with own configuration 41 | - Optimize your needs 42 | - [@textlint/script-compiler](packages/@textlint/script-compiler) is code generator 43 | 44 | [Grammarly](https://grammarly.com/) and [Microsoft Editor](https://www.microsoft.com/microsoft-365/microsoft-editor) is 45 | useful and high-quality linting tools, but these require network access, and you must pass your text to their server. 46 | 47 | [textlint](https://github.com/textlint/textlint) can be works at offline. Because, textlint is written by JavaScript, 48 | textlint rules are also written by JavaScript. 49 | 50 | However, textlint is pluggable linting tools and textlint can not provide recommended/default ruleset. 51 | 52 | @textlint/editor project resolve this issue using [@textlint/script-compiler](packages/@textlint/script-compiler) that 53 | generate optimized code from your textlint configuration. 54 | 55 | ![Architecture](docs/resources/textlint_editor.png) 56 | 57 | 58 | 59 | For example, WebExtension download own optimized textlint that is generated 60 | code [@textlint/script-compiler](packages/@textlint/script-compiler), and use it for linting. 61 | 62 | So, we can focus on the compiler and frontend of editor. 63 | 64 | ## Develop 65 | 66 | Install with yarn and build before editing files. 67 | 68 | yarn install 69 | yarn run build 70 | cd packages/you want to edit 71 | 72 | ### Develop web extension 73 | 74 | yarn install 75 | yarn run build 76 | cd packages/webextension 77 | yarn dev chrome # yarn dev firefox 78 | 79 | ## Architecture 80 | 81 | - FrontEnd 82 | - [textchecker-element](packages/textchecker-element) is general web component implementation. 83 | - Injectable code 84 | - View 85 | - multiple implementations 86 | - For VSCode, TextArea, Google Docs 87 | - BackEnd 88 | - Web Extension: background.js 89 | - Server: API server 90 | - Web Worker: thread 91 | - spellchecker backend api 92 | 93 | FrontEnd and BackEnd is separated. 94 | 95 | ### WebComponent 96 | 97 | Avoid side-effect on website. 98 | 99 | - TextChecker 100 | - Controller 101 | - Portal Overlay 102 | 103 | ### Compiler target 104 | 105 | [@textlint/script-compiler](packages/@textlint/script-compiler) generate bundled JavaScript code. 106 | 107 | Compiler compilertextlint + rule + textlintrc into a single library code. 108 | 109 | - Chrome Extension code 110 | - chrome.storage.local for cache 111 | - libraryTarget: 112 | - Web Worker code 113 | - kvstorage cache 114 | - libraryTarget: self 115 | - Main Thread code(just web) 116 | - kvstorage cache 117 | - libraryTarget: web 118 | 119 | Also, We can provide [@textlint/script-compiler](packages/@textlint/script-compiler) as a service 120 | using [codesandbox](https://codesandbox.io) 121 | 122 | ### API 123 | 124 | The library has some API 125 | 126 | - update(config): Promise 127 | - dynamic update textlintrc config 128 | - lint({text:string}): { range: [number, number], message: string, suggestions: suggesionItem[] }; 129 | - fix({ range: [number,number] }): string; 130 | - suggest({ range: [number, numbe })` 131 | - missing parts of textlint 132 | - `ignore({ word:string }): Promise` 133 | - [textlint-filter-rule-allowlist](https://github.com/textlint/textlint-filter-rule-allowlist) configuration? 134 | 135 | ## Changelog 136 | 137 | See [Releases page](https://github.com/textlint/editor/releases). 138 | 139 | ## Running tests 140 | 141 | Install devDependencies and Run `npm test`: 142 | 143 | npm test 144 | 145 | ## Contributing 146 | 147 | Pull requests and stars are always welcome. 148 | 149 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 150 | 151 | 1. Fork it! 152 | 2. Create your feature branch: `git checkout -b my-new-feature` 153 | 3. Commit your changes: `git commit -am 'Add some feature'` 154 | 4. Push to the branch: `git push origin my-new-feature` 155 | 5. Submit a pull request :D 156 | 157 | ## Author 158 | 159 | - [github/azu](https://github.com/azu) 160 | - [twitter/azu_re](https://twitter.com/azu_re) 161 | 162 | ## License 163 | 164 | MIT © azu 165 | -------------------------------------------------------------------------------- /docs/create-textlint-worker.md: -------------------------------------------------------------------------------- 1 | # Create textlint worker script 2 | 3 | If you want to get own textlint worker script with own configuration, you can create textlint worker using `@textlint/script-compiler` or `@textlint/website-generator`. 4 | 5 | ## How to create 6 | 7 | 1. Setup `.textlintrc` 8 | 2. `npx @textlint/website-generator --output-dir ./dist` 9 | 3. Publish the output as web page using GitHub Pages. 10 | 11 | ## Quick Start 12 | 13 | 1. 14 | -------------------------------------------------------------------------------- /docs/resources/textlint_editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/textlint/editor/68623636d9d407c041946800818954c7972ba888/docs/resources/textlint_editor.png -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "useWorkspaces": true, 3 | "npmClient": "yarn", 4 | "version": "0.17.0" 5 | } 6 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | # example netlify.toml 2 | [build] 3 | command = "yarn run build && yarn run website" 4 | functions = "functions" 5 | publish = "packages/textchecker-element/dist" 6 | 7 | ## Uncomment to use this redirect for Single Page Applications like create-react-app. 8 | ## Not needed for static site generators. 9 | #[[redirects]] 10 | # from = "/*" 11 | # to = "/index.html" 12 | # status = 200 13 | 14 | ## (optional) Settings for Netlify Dev 15 | ## https://github.com/netlify/cli/blob/master/docs/netlify-dev.md#project-detection 16 | #[dev] 17 | # command = "yarn start" # Command to start your dev server 18 | # port = 3000 # Port that the dev server will be listening on 19 | # publish = "dist" # Folder with the static content for _redirect file 20 | 21 | ## more info on configuring this file: https://www.netlify.com/docs/netlify-toml-reference/ 22 | -------------------------------------------------------------------------------- /nx.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasksRunnerOptions": { 3 | "default": { 4 | "runner": "nx/tasks-runners/default", 5 | "options": { 6 | "cacheableOperations": [ 7 | "build", 8 | "build:public-lib", 9 | "website-generator", 10 | "build:example" 11 | ] 12 | } 13 | } 14 | }, 15 | "targetDefaults": { 16 | "compile:textlint": { 17 | "dependsOn": [ 18 | "^compile:textlint" 19 | ] 20 | }, 21 | "predev": { 22 | "dependsOn": [ 23 | "^predev" 24 | ] 25 | }, 26 | "website": { 27 | "dependsOn": [ 28 | "^website" 29 | ] 30 | }, 31 | "build": { 32 | "dependsOn": [ 33 | "^build" 34 | ], 35 | "outputs": [ 36 | "{projectRoot}/dist", 37 | "{projectRoot}/lib", 38 | "{projectRoot}/module", 39 | "{projectRoot}/example" 40 | ] 41 | }, 42 | "build:public-lib": { 43 | "dependsOn": [ 44 | "^build:public-lib" 45 | ], 46 | "outputs": [ 47 | "{projectRoot}/public-dist" 48 | ] 49 | }, 50 | "website-generator": { 51 | "dependsOn": [ 52 | "^website-generator" 53 | ], 54 | "outputs": [ 55 | "{projectRoot}/dist", 56 | "{projectRoot}/template" 57 | ] 58 | }, 59 | "test": { 60 | "dependsOn": [ 61 | "^test" 62 | ] 63 | }, 64 | "prebuild:example": { 65 | "dependsOn": [ 66 | "^prebuild:example" 67 | ] 68 | }, 69 | "build:example": { 70 | "dependsOn": [ 71 | "^build:example" 72 | ], 73 | "outputs": [ 74 | "{projectRoot}/lib", 75 | "{projectRoot}/module" 76 | ] 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "@textlint/editor", 4 | "version": "0.1.0", 5 | "description": "textlint editor project.", 6 | "homepage": "https://github.com/textlint/editor", 7 | "bugs": { 8 | "url": "https://github.com/textlint/editor/issues" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/textlint/editor.git" 13 | }, 14 | "license": "MIT", 15 | "author": "azu", 16 | "main": "lib/editor.js", 17 | "directories": { 18 | "lib": "lib", 19 | "test": "test" 20 | }, 21 | "workspaces": [ 22 | "packages/*", 23 | "packages/@textlint/*", 24 | "examples/*" 25 | ], 26 | "files": [ 27 | "bin/", 28 | "lib/" 29 | ], 30 | "scripts": { 31 | "build": "lerna run build", 32 | "test": "lerna run build && lerna run test", 33 | "website": "cd packages/textchecker-element && yarn run website", 34 | "versionup": "lerna version", 35 | "ci:versionup:patch": "lerna version patch --no-push --no-git-tag-version --yes && npm run commit-version", 36 | "ci:versionup:minor": "lerna version minor --no-push --no-git-tag-version --yes && npm run commit-version", 37 | "ci:versionup:major": "lerna version major --no-push --no-git-tag-version --yes && npm run commit-version", 38 | "commit-version": "git add . && git commit -m \"chore(release): v`node -p 'require(\"./lerna.json\").version'`\"", 39 | "release": "lerna publish from-package", 40 | "ci:release": "lerna publish from-package --yes", 41 | "format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 42 | "prepare": "git config --local core.hooksPath .githooks" 43 | }, 44 | "publishConfig": { 45 | "access": "public" 46 | }, 47 | "devDependencies": { 48 | "lerna": "^6.4.1", 49 | "lint-staged": "^13.1.1", 50 | "prettier": "^2.8.4" 51 | }, 52 | "prettier": { 53 | "singleQuote": false, 54 | "printWidth": 120, 55 | "tabWidth": 4, 56 | "trailingComma": "none" 57 | }, 58 | "lint-staged": { 59 | "*.{js,jsx,ts,tsx,css}": [ 60 | "prettier --write" 61 | ] 62 | }, 63 | "packageManager": "yarn@1.22.19" 64 | } 65 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | .env.test 60 | 61 | # parcel-bundler cache (https://parceljs.org/) 62 | .cache 63 | 64 | # next.js build output 65 | .next 66 | 67 | # nuxt.js build output 68 | .nuxt 69 | 70 | # vuepress build output 71 | .vuepress/dist 72 | 73 | # Serverless directories 74 | .serverless/ 75 | 76 | # FuseBox cache 77 | .fusebox/ 78 | 79 | # DynamoDB Local files 80 | .dynamodb/ 81 | 82 | 83 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 84 | 85 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 86 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 87 | 88 | # User-specific stuff 89 | .idea/**/workspace.xml 90 | .idea/**/tasks.xml 91 | .idea/**/usage.statistics.xml 92 | .idea/**/dictionaries 93 | .idea/**/shelf 94 | 95 | # Generated files 96 | .idea/**/contentModel.xml 97 | 98 | # Sensitive or high-churn files 99 | .idea/**/dataSources/ 100 | .idea/**/dataSources.ids 101 | .idea/**/dataSources.local.xml 102 | .idea/**/sqlDataSources.xml 103 | .idea/**/dynamic.xml 104 | .idea/**/uiDesigner.xml 105 | .idea/**/dbnavigator.xml 106 | 107 | # Gradle 108 | .idea/**/gradle.xml 109 | .idea/**/libraries 110 | 111 | # Gradle and Maven with auto-import 112 | # When using Gradle or Maven with auto-import, you should exclude module files, 113 | # since they will be recreated, and may cause churn. Uncomment if using 114 | # auto-import. 115 | # .idea/modules.xml 116 | # .idea/*.iml 117 | # .idea/modules 118 | 119 | # CMake 120 | cmake-build-*/ 121 | 122 | # Mongo Explorer plugin 123 | .idea/**/mongoSettings.xml 124 | 125 | # File-based project format 126 | *.iws 127 | 128 | # IntelliJ 129 | out/ 130 | 131 | # mpeltonen/sbt-idea plugin 132 | .idea_modules/ 133 | 134 | # JIRA plugin 135 | atlassian-ide-plugin.xml 136 | 137 | # Cursive Clojure plugin 138 | .idea/replstate.xml 139 | 140 | # Crashlytics plugin (for Android Studio and IntelliJ) 141 | com_crashlytics_export_strings.xml 142 | crashlytics.properties 143 | crashlytics-build.properties 144 | fabric.properties 145 | 146 | # Editor-based Rest Client 147 | .idea/httpRequests 148 | 149 | # Android studio 3.1+ serialized cache file 150 | .idea/caches/build_file_checksums.ser 151 | 152 | 153 | # Build files 154 | /lib 155 | /module 156 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [0.12.0](https://github.com/textlint/editor/compare/v0.11.3...v0.12.0) (2021-05-24) 7 | 8 | 9 | ### Features 10 | 11 | * **deps:** update to textlint@12 ([#50](https://github.com/textlint/editor/issues/50)) ([a459ba3](https://github.com/textlint/editor/commit/a459ba3962ac853a82b1485f7023b4625f940372)) 12 | 13 | 14 | 15 | 16 | 17 | ## [0.11.3](https://github.com/textlint/editor/compare/v0.11.2...v0.11.3) (2021-05-15) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * use dirname ([8bf1119](https://github.com/textlint/editor/commit/8bf111951d811fede79256d62e58a5846e50e7ff)) 23 | 24 | 25 | ### Features 26 | 27 | * support @textlint/config-inliner in compiler ([630fd1e](https://github.com/textlint/editor/commit/630fd1ee938a2b39e8ae74afdbde157497125557)) 28 | * **compiler:** support to inline prh.yml ([#47](https://github.com/textlint/editor/issues/47)) ([b06e3b2](https://github.com/textlint/editor/commit/b06e3b23332f0f4b0d55ebc8e4b2f923c095bfa6)) 29 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2021 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/config-inliner 2 | 3 | Inlining config for supporting browser. 4 | 5 | Some rules use `fs`, so `fs` module does not work in a browser. 6 | Instead of using `fs`, inlining the content before compiling by `@textlint/script-compiler`. 7 | 8 | [textlint-scripts build](https://github.com/textlint/textlint-scripts#textlint-scripts-build) inlining `fs` usage by default. 9 | 10 | `@textlint/config-inliner`'s target is `.textlintrc` configration file. 11 | 12 | - [ ] TODO: we need to defined common rule for inlining. 13 | 14 | ## Supported Rules 15 | 16 | - [x] [textlint-rule-prh](https://github.com/textlint-rule/textlint-rule-prh) 17 | 18 | ## Install 19 | 20 | Install with [npm](https://www.npmjs.com/): 21 | 22 | npm install @textlint/config-inliner 23 | 24 | ## Usage 25 | 26 | ```ts 27 | import { loadConfig } from "@textlint/config-loader"; 28 | import { inlineConfig } from "@textlint/config-inliner"; 29 | const configResult = await loadConfig(); 30 | const inlinedConfig = await inlineConfig({ 31 | cwd: process.cwd(), 32 | configFilePath: configResult.configFilePath, 33 | config: configResult.config 34 | }); 35 | ``` 36 | 37 | ## Changelog 38 | 39 | See [Releases page](https://github.com/textlint/editor/releases). 40 | 41 | ## Running tests 42 | 43 | Install devDependencies and Run `npm test`: 44 | 45 | npm test 46 | 47 | ## Contributing 48 | 49 | Pull requests and stars are always welcome. 50 | 51 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 52 | 53 | 1. Fork it! 54 | 2. Create your feature branch: `git checkout -b my-new-feature` 55 | 3. Commit your changes: `git commit -am 'Add some feature'` 56 | 4. Push to the branch: `git push origin my-new-feature` 57 | 5. Submit a pull request :D 58 | 59 | ## Author 60 | 61 | - azu: [GitHub](https://github.com/azu), [Twitter](https://twitter.com/azu_re) 62 | 63 | ## License 64 | 65 | MIT © azu 66 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/config-inliner", 3 | "version": "0.17.0", 4 | "description": "Inlining config for supporting browser.", 5 | "keywords": [ 6 | "textlint" 7 | ], 8 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/config-inliner/", 9 | "bugs": { 10 | "url": "https://github.com/textlint/editor/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/textlint/editor.git" 15 | }, 16 | "license": "MIT", 17 | "author": "azu", 18 | "sideEffects": false, 19 | "main": "lib/config-inliner.js", 20 | "module": "module/config-inliner.js", 21 | "types": "lib/config-inliner.d.ts", 22 | "directories": { 23 | "lib": "lib", 24 | "test": "test" 25 | }, 26 | "files": [ 27 | "bin/", 28 | "lib/", 29 | "module/", 30 | "src/" 31 | ], 32 | "scripts": { 33 | "test": "mocha \"test/**/*.ts\"", 34 | "format": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 35 | "build": "tsc -p . && tsc -p ./tsconfig.module.json", 36 | "watch": "tsc -p . --watch", 37 | "clean": "rimraf lib/ module/", 38 | "prepublishOnly": "npm run clean && npm run build" 39 | }, 40 | "prettier": { 41 | "printWidth": 120, 42 | "singleQuote": false, 43 | "tabWidth": 4, 44 | "trailingComma": "none" 45 | }, 46 | "dependencies": { 47 | "@textlint/config-loader": "^14.0.4", 48 | "untildify": "^4.0.0" 49 | }, 50 | "devDependencies": { 51 | "@types/mocha": "^10.0.1", 52 | "@types/node": "^18.13.0", 53 | "mocha": "^10.8.2", 54 | "prettier": "^2.3.0", 55 | "rimraf": "^3.0.2", 56 | "ts-node": "^10.9.1", 57 | "ts-node-test-register": "^10.0.0", 58 | "typescript": "^4.9.5" 59 | }, 60 | "publishConfig": { 61 | "access": "public" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/src/config-inliner.ts: -------------------------------------------------------------------------------- 1 | import type { TextlintConfigDescriptor } from "@textlint/config-loader"; 2 | import { prh } from "./rules/prh"; 3 | 4 | export const inlineConfig = async ({ 5 | cwd = process.cwd(), 6 | configFilePath, 7 | config 8 | }: { 9 | cwd?: string; 10 | configFilePath: string; 11 | config: TextlintConfigDescriptor; 12 | }): Promise => { 13 | return { 14 | ...config, 15 | rules: await Promise.all( 16 | config.rules.map(async (rule) => { 17 | if (rule.ruleId === "prh") { 18 | return { 19 | ...rule, 20 | options: await prh({ 21 | cwd, 22 | configFilePath, 23 | options: rule.options 24 | }) 25 | }; 26 | } 27 | return rule; 28 | }) 29 | ) 30 | }; 31 | }; 32 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/src/rules/prh.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs/promises"; 2 | import untildify from "untildify"; 3 | import { TextlintRuleOptions } from "@textlint/types"; 4 | import path from "path"; 5 | 6 | const inlineRuleFiles = (filePaths: string[], baseDir: string): Promise => { 7 | return Promise.all( 8 | filePaths.map((filePath) => { 9 | return fs.readFile(path.resolve(baseDir, untildify(filePath)), "utf-8"); 10 | }) 11 | ); 12 | }; 13 | type PrhOptions = 14 | | { rulePaths: string[] } 15 | | ({ 16 | ruleContents: string[]; 17 | } & TextlintRuleOptions); 18 | /** 19 | * use `ruleContents` instead of `rulePaths` for inlining 20 | * https://github.com/textlint-rule/textlint-rule-prh 21 | */ 22 | export const prh = async ({ 23 | configFilePath, 24 | options 25 | }: { 26 | cwd?: string; 27 | configFilePath: string; 28 | options: TextlintRuleOptions | undefined | boolean; 29 | }): Promise => { 30 | if (typeof options === "boolean" || options === undefined) { 31 | return options; 32 | } 33 | const baseDir = path.dirname(configFilePath); 34 | return { 35 | ...options, 36 | rulePaths: [], 37 | ruleContents: await inlineRuleFiles(options.rulePaths, baseDir) 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/test/fixtures/prh/prh.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | rules: 3 | - expected: jQuery 4 | specs: 5 | - from: jquery 6 | to: jQuery 7 | - from: JQUERY 8 | to: jQuery 9 | 10 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/test/prh.test.ts: -------------------------------------------------------------------------------- 1 | import { prh } from "../src/rules/prh"; 2 | import path from "path"; 3 | import assert from "assert"; 4 | import * as fs from "fs"; 5 | 6 | describe("prh", function () { 7 | it("inline rulePaths to ruleContents", async () => { 8 | const prhOptions = await prh({ 9 | configFilePath: path.join(__dirname, "fixtures/prh/.textlintrc"), 10 | options: { 11 | rulePaths: [path.join(__dirname, "fixtures/prh/prh.yml")] 12 | } 13 | }); 14 | assert.deepStrictEqual(prhOptions, { 15 | rulePaths: [], 16 | ruleContents: [fs.readFileSync(path.join(__dirname, "fixtures/prh/prh.yml"), "utf-8")] 17 | }); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "es5", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "lib": [ 14 | "esnext", 15 | "dom" 16 | ], 17 | /* Strict Type-Checking Options */ 18 | "strict": true, 19 | /* Additional Checks */ 20 | /* Report errors on unused locals. */ 21 | "noUnusedLocals": true, 22 | /* Report errors on unused parameters. */ 23 | "noUnusedParameters": true, 24 | /* Report error when not all code paths in function return a value. */ 25 | "noImplicitReturns": true, 26 | /* Report errors for fallthrough cases in switch statement. */ 27 | "noFallthroughCasesInSwitch": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ], 32 | "exclude": [ 33 | ".git", 34 | "node_modules" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/@textlint/config-inliner/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | .env.test 62 | 63 | # parcel-bundler cache (https://parceljs.org/) 64 | .cache 65 | 66 | # next.js build output 67 | .next 68 | 69 | # nuxt.js build output 70 | .nuxt 71 | 72 | # vuepress build output 73 | .vuepress/dist 74 | 75 | # Serverless directories 76 | .serverless/ 77 | 78 | # FuseBox cache 79 | .fusebox/ 80 | 81 | # DynamoDB Local files 82 | .dynamodb/ 83 | 84 | 85 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 86 | 87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 88 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 89 | 90 | # User-specific stuff 91 | .idea/**/workspace.xml 92 | .idea/**/tasks.xml 93 | .idea/**/usage.statistics.xml 94 | .idea/**/dictionaries 95 | .idea/**/shelf 96 | 97 | # Generated files 98 | .idea/**/contentModel.xml 99 | 100 | # Sensitive or high-churn files 101 | .idea/**/dataSources/ 102 | .idea/**/dataSources.ids 103 | .idea/**/dataSources.local.xml 104 | .idea/**/sqlDataSources.xml 105 | .idea/**/dynamic.xml 106 | .idea/**/uiDesigner.xml 107 | .idea/**/dbnavigator.xml 108 | 109 | # Gradle 110 | .idea/**/gradle.xml 111 | .idea/**/libraries 112 | 113 | # Gradle and Maven with auto-import 114 | # When using Gradle or Maven with auto-import, you should exclude module files, 115 | # since they will be recreated, and may cause churn. Uncomment if using 116 | # auto-import. 117 | # .idea/modules.xml 118 | # .idea/*.iml 119 | # .idea/modules 120 | 121 | # CMake 122 | cmake-build-*/ 123 | 124 | # Mongo Explorer plugin 125 | .idea/**/mongoSettings.xml 126 | 127 | # File-based project format 128 | *.iws 129 | 130 | # IntelliJ 131 | out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Cursive Clojure plugin 140 | .idea/replstate.xml 141 | 142 | # Crashlytics plugin (for Android Studio and IntelliJ) 143 | com_crashlytics_export_strings.xml 144 | crashlytics.properties 145 | crashlytics-build.properties 146 | fabric.properties 147 | 148 | # Editor-based Rest Client 149 | .idea/httpRequests 150 | 151 | # Android studio 3.1+ serialized cache file 152 | .idea/caches/build_file_checksums.ser 153 | 154 | 155 | # Build files 156 | /lib 157 | /module 158 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [0.12.0](https://github.com/textlint/editor/compare/v0.11.3...v0.12.0) (2021-05-24) 7 | 8 | 9 | ### Features 10 | 11 | * **deps:** update to textlint@12 ([#50](https://github.com/textlint/editor/issues/50)) ([a459ba3](https://github.com/textlint/editor/commit/a459ba3962ac853a82b1485f7023b4625f940372)) 12 | 13 | 14 | 15 | 16 | 17 | ## [0.11.3](https://github.com/textlint/editor/compare/v0.11.2...v0.11.3) (2021-05-15) 18 | 19 | 20 | ### Features 21 | 22 | * support @textlint/config-inliner in compiler ([630fd1e](https://github.com/textlint/editor/commit/630fd1ee938a2b39e8ae74afdbde157497125557)) 23 | 24 | 25 | 26 | 27 | 28 | # [0.11.0](https://github.com/textlint/editor/compare/v0.10.5...v0.11.0) (2021-05-02) 29 | 30 | **Note:** Version bump only for package @textlint/config-partial-parser 31 | 32 | 33 | 34 | 35 | 36 | ## [0.10.4](https://github.com/textlint/editor/compare/v0.10.3...v0.10.4) (2021-04-19) 37 | 38 | **Note:** Version bump only for package @textlint/config-partial-parser 39 | 40 | 41 | 42 | 43 | 44 | ## [0.10.2](https://github.com/textlint/editor/compare/v0.10.1...v0.10.2) (2021-04-18) 45 | 46 | **Note:** Version bump only for package @textlint/config-partial-parser 47 | 48 | 49 | 50 | 51 | 52 | # [0.10.0](https://github.com/textlint/editor/compare/v0.9.3...v0.10.0) (2021-04-18) 53 | 54 | **Note:** Version bump only for package @textlint/config-partial-parser 55 | 56 | 57 | 58 | 59 | 60 | # [0.9.0](https://github.com/textlint/editor/compare/v0.8.2...v0.9.0) (2021-04-17) 61 | 62 | 63 | ### Features 64 | 65 | * support "ignore" feature ([ef14d33](https://github.com/textlint/editor/commit/ef14d337c48150d99dd853cac243a988d3244727)) 66 | 67 | 68 | 69 | 70 | 71 | # [0.8.0](https://github.com/textlint/editor/compare/v0.7.1...v0.8.0) (2020-10-27) 72 | 73 | 74 | ### Features 75 | 76 | * support "merge-config" command ([e7f734e](https://github.com/textlint/editor/commit/e7f734eb2e1e44d85592159f37d3a83ab50f7966)) 77 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/config-partial-parser 2 | 3 | A partial parser for textlintrc. 4 | 5 | It is parser for textlintrc, it is not loader. 6 | 7 | The loader is `@textlint/config-loader` 8 | 9 | ## Install 10 | 11 | Install with [npm](https://www.npmjs.com/): 12 | 13 | npm install @textlint/config-partial-parser 14 | 15 | ## Usage 16 | 17 | - [ ] Write usage instructions 18 | 19 | ## Changelog 20 | 21 | See [Releases page](https://github.com/textlint/editor/releases). 22 | 23 | ## Running tests 24 | 25 | Install devDependencies and Run `npm test`: 26 | 27 | npm test 28 | 29 | ## Contributing 30 | 31 | Pull requests and stars are always welcome. 32 | 33 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 34 | 35 | 1. Fork it! 36 | 2. Create your feature branch: `git checkout -b my-new-feature` 37 | 3. Commit your changes: `git commit -am 'Add some feature'` 38 | 4. Push to the branch: `git push origin my-new-feature` 39 | 5. Submit a pull request :D 40 | 41 | ## Author 42 | 43 | - azu: [GitHub](https://github.com/azu), [Twitter](https://twitter.com/azu_re) 44 | 45 | ## License 46 | 47 | MIT © azu 48 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/config-partial-parser", 3 | "version": "0.17.0", 4 | "description": "A partial parser for textlintrc", 5 | "keywords": [ 6 | "textlint", 7 | "config" 8 | ], 9 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/config-partial-parser/", 10 | "bugs": { 11 | "url": "https://github.com/textlint/editor/issues" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/textlint/editor.git" 16 | }, 17 | "license": "MIT", 18 | "author": "azu", 19 | "sideEffects": false, 20 | "main": "lib/index.js", 21 | "module": "module/index.js", 22 | "types": "lib/index.d.ts", 23 | "directories": { 24 | "lib": "lib", 25 | "test": "test" 26 | }, 27 | "files": [ 28 | "bin/", 29 | "lib/", 30 | "module" 31 | ], 32 | "scripts": { 33 | "build": "tsc -p . && tsc -p ./tsconfig.module.json", 34 | "clean": "rimraf lib/ module/", 35 | "prepublishOnly": "npm run clean && npm run build", 36 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 37 | "test": "mocha \"test/**/*.ts\"", 38 | "watch": "tsc -p . --watch" 39 | }, 40 | "prettier": { 41 | "printWidth": 120, 42 | "singleQuote": false, 43 | "tabWidth": 4, 44 | "trailingComma": "none" 45 | }, 46 | "dependencies": { 47 | "@textlint/config-loader": "^14.0.4", 48 | "@textlint/kernel": "^14.0.4", 49 | "@textlint/types": "^14.0.4", 50 | "@textlint/utils": "^14.0.4" 51 | }, 52 | "devDependencies": { 53 | "@types/mocha": "^10.0.1", 54 | "@types/node": "^18.13.0", 55 | "mocha": "^10.8.2", 56 | "prettier": "^2.3.0", 57 | "rimraf": "^3.0.2", 58 | "ts-node": "^10.9.1", 59 | "ts-node-test-register": "^10.0.0", 60 | "typescript": "^4.9.5" 61 | }, 62 | "publishConfig": { 63 | "access": "public" 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/src/TextlintConfigDescriptor.ts: -------------------------------------------------------------------------------- 1 | import type { TextlintKernelFilterRule, TextlintKernelPlugin, TextlintKernelRule } from "@textlint/kernel"; 2 | 3 | /** 4 | * Parsable static config data 5 | */ 6 | export type TextlintStaticOptionPlugin = Pick; 7 | export type TextlintStaticOptionRule = Pick; 8 | export type TextlintStaticOptionFilterRule = Pick; 9 | export type TextlintStaticOptionDescriptor = { 10 | // plugins 11 | plugins: TextlintStaticOptionPlugin[]; 12 | // rules -includes expands presets 13 | rules: TextlintStaticOptionRule[]; 14 | // filterRules 15 | filterRules: TextlintStaticOptionFilterRule[]; 16 | }; 17 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/src/TextlintRcConfig.ts: -------------------------------------------------------------------------------- 1 | export type TextlintRcConfig = { 2 | plugins?: 3 | | string[] 4 | | { 5 | [index: string]: boolean | {}; 6 | }; 7 | filters?: { 8 | [index: string]: boolean | {}; 9 | }; 10 | rules?: { 11 | [index: string]: boolean | {}; 12 | }; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/src/config-util.ts: -------------------------------------------------------------------------------- 1 | export function isPluginRuleKey(key: string) { 2 | // @/<>rule> 3 | if (key[0] === "@" && key.indexOf("/textlint-plugin") !== -1) { 4 | return true; 5 | } 6 | // not contain @, but contain / 7 | // / 8 | return key[0] !== "@" && key.indexOf("/") !== -1; 9 | } 10 | 11 | export function isPresetRuleKey(key: string) { 12 | // "preset-name" is special pattern 13 | if (/^preset-/.test(key)) { 14 | return true; 15 | } 16 | if (/^textlint-rule-preset-/.test(key)) { 17 | return true; 18 | } 19 | // scoped module: @textlint/textlint-rule-preset-foo 20 | if (key[0] === "@") { 21 | if (key.indexOf("/preset-") !== -1 || key.indexOf("/textlint-rule-preset-") !== -1) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/src/index.ts: -------------------------------------------------------------------------------- 1 | import { TextlintRcConfig } from "@textlint/config-loader"; 2 | import { TextlintStaticOptionDescriptor } from "./TextlintConfigDescriptor"; 3 | import { parseFilterRules, parsePlugins, parseRules } from "./parser"; 4 | 5 | /** 6 | * Parse textlintrc and return parsed config 7 | * Note: the pserse function does not load any module 8 | * In other words, the result does not includes presets.rulesConfig 9 | */ 10 | export const parseOptionsFromConfig = (rawConfig: TextlintRcConfig): TextlintStaticOptionDescriptor => { 11 | // rules 12 | const { rules } = parseRules({ 13 | rulesObject: rawConfig.rules ?? {} 14 | }); 15 | // filterRules 16 | const { filterRules } = parseFilterRules({ 17 | rulesObject: rawConfig.filters ?? {} 18 | }); 19 | // plugins 20 | const { plugins } = parsePlugins({ 21 | pluginsObject: rawConfig.plugins ?? {} 22 | }); 23 | return { 24 | rules, 25 | plugins, 26 | filterRules 27 | }; 28 | }; 29 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/src/parser.ts: -------------------------------------------------------------------------------- 1 | import { isPresetRuleKey } from "./config-util"; 2 | import { TextlintRcConfig } from "./TextlintRcConfig"; 3 | import { TextlintStaticOptionDescriptor } from "./TextlintConfigDescriptor"; 4 | import { normalizeTextlintPresetSubRuleKey } from "@textlint/utils"; 5 | 6 | export const parsePlugins = ({ 7 | pluginsObject 8 | }: { 9 | pluginsObject: NonNullable; 10 | parentPresetName?: string; 11 | }): { 12 | plugins: TextlintStaticOptionDescriptor["plugins"]; 13 | } => { 14 | const plugins: TextlintStaticOptionDescriptor["plugins"] = []; 15 | if (Array.isArray(pluginsObject)) { 16 | // { plugins: ["a", "b"] } 17 | pluginsObject.forEach((pluginId) => { 18 | plugins.push({ 19 | pluginId: pluginId 20 | }); 21 | }); 22 | } else { 23 | // { plugins: { "a": true, "b": options } } 24 | Object.entries(pluginsObject).forEach(([pluginId, pluginOptions]) => { 25 | plugins.push({ 26 | pluginId: pluginId, 27 | options: pluginOptions 28 | }); 29 | }); 30 | } 31 | return { 32 | plugins 33 | }; 34 | }; 35 | export const parseFilterRules = ({ 36 | rulesObject 37 | }: { 38 | rulesObject: NonNullable; 39 | }): { 40 | filterRules: TextlintStaticOptionDescriptor["filterRules"]; 41 | } => { 42 | // rules 43 | const rules: TextlintStaticOptionDescriptor["filterRules"] = []; 44 | Object.entries(rulesObject).forEach(([ruleId, ruleOptions]) => { 45 | // rule 46 | rules.push({ 47 | ruleId: ruleId, 48 | options: ruleOptions 49 | }); 50 | }); 51 | return { 52 | filterRules: rules 53 | }; 54 | }; 55 | export const parseRules = ({ 56 | rulesObject 57 | }: { 58 | rulesObject: NonNullable; 59 | }): { 60 | rules: TextlintStaticOptionDescriptor["rules"]; 61 | } => { 62 | // rules 63 | const rules: TextlintStaticOptionDescriptor["rules"] = []; 64 | Object.entries(rulesObject).forEach(([ruleId, ruleOptions]) => { 65 | if (isPresetRuleKey(ruleId) && typeof ruleOptions !== "boolean") { 66 | // parse preset 67 | Object.entries(ruleOptions).forEach(([presetRuleKey, presetRuleOption]) => { 68 | const normalizedKey = normalizeTextlintPresetSubRuleKey({ preset: ruleId, rule: presetRuleKey }); 69 | rules.push({ 70 | ruleId: normalizedKey, 71 | options: presetRuleOption 72 | }); 73 | }); 74 | } else { 75 | // rule 76 | rules.push({ 77 | ruleId: ruleId, 78 | options: ruleOptions 79 | }); 80 | } 81 | }); 82 | return { 83 | rules 84 | }; 85 | }; 86 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/index.test.ts: -------------------------------------------------------------------------------- 1 | import * as fs from "fs"; 2 | import * as path from "path"; 3 | import * as assert from "assert"; 4 | import { parseOptionsFromConfig } from "../src"; 5 | 6 | const fixturesDir = path.join(__dirname, "snapshots"); 7 | describe("parseOptionsFromConfig", () => { 8 | fs.readdirSync(fixturesDir).map((caseName) => { 9 | const normalizedTestName = caseName.replace(/-/g, " "); 10 | it(`Test ${normalizedTestName}`, async function () { 11 | const fixtureDir = path.join(fixturesDir, caseName); 12 | const actualFilePath = path.join(fixtureDir, "input.json"); 13 | const actualContent = JSON.parse(fs.readFileSync(actualFilePath, "utf-8")); 14 | const actual = parseOptionsFromConfig(actualContent); 15 | const expectedFilePath = path.join(fixtureDir, "output.json"); 16 | // Usage: update snapshots 17 | // UPDATE_SNAPSHOT=1 npm test 18 | if (!fs.existsSync(expectedFilePath) || process.env.UPDATE_SNAPSHOT) { 19 | fs.writeFileSync(expectedFilePath, JSON.stringify(actual, null, 4)); 20 | this.skip(); // skip when updating snapshots 21 | return; 22 | } 23 | // compare input and output 24 | const expectedContent = JSON.parse(fs.readFileSync(expectedFilePath, "utf-8")); 25 | assert.deepStrictEqual( 26 | // remove undefined 27 | JSON.parse(JSON.stringify(actual)), 28 | expectedContent 29 | ); 30 | }); 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-a/index.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return {}; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-a/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textlint-rule-a", 3 | "main": "index.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-b/index.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return {}; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-b/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textlint-rule-b", 3 | "main": "index.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-c-sub1/index.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return {}; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-c-sub1/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textlint-rule-c-sub1", 3 | "main": "index.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-c-sub2/index.js: -------------------------------------------------------------------------------- 1 | module.exports = () => { 2 | return {}; 3 | }; 4 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-c-sub2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textlint-rule-c-sub2", 3 | "main": "index.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-preset-c/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rules: { 3 | "c-sub1": require("../textlint-rule-c-sub1"), 4 | "c-sub2": require("../textlint-rule-c-sub2") 5 | }, 6 | rulesConfig: { 7 | "c-sub1": true, 8 | "c-sub2": true 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/modules_fixtures/textlint-rule-preset-c/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "textlint-rule-b", 3 | "main": "index.js" 4 | } 5 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/snapshots/plguin/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "custom" 4 | ], 5 | "rules": { 6 | "a": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/snapshots/plguin/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": [ 3 | { 4 | "ruleId": "a", 5 | "options": true 6 | } 7 | ], 8 | "plugins": [ 9 | { 10 | "pluginId": "custom" 11 | } 12 | ], 13 | "filterRules": [] 14 | } -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/snapshots/rules/input.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-use": false, 4 | "a": true, 5 | "b": { 6 | "key": "value" 7 | }, 8 | "preset-c": { 9 | "c-sub1": false 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/snapshots/rules/output.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": [ 3 | { 4 | "ruleId": "no-use", 5 | "options": false 6 | }, 7 | { 8 | "ruleId": "a", 9 | "options": true 10 | }, 11 | { 12 | "ruleId": "b", 13 | "options": { 14 | "key": "value" 15 | } 16 | }, 17 | { 18 | "ruleId": "c/c-sub1", 19 | "options": false 20 | } 21 | ], 22 | "plugins": [], 23 | "filterRules": [] 24 | } 25 | -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "es5", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "lib": [ 14 | "esnext", 15 | "dom" 16 | ], 17 | /* Strict Type-Checking Options */ 18 | "strict": true, 19 | /* Additional Checks */ 20 | /* Report errors on unused locals. */ 21 | "noUnusedLocals": true, 22 | /* Report errors on unused parameters. */ 23 | "noUnusedParameters": true, 24 | /* Report error when not all code paths in function return a value. */ 25 | "noImplicitReturns": true, 26 | /* Report errors for fallthrough cases in switch statement. */ 27 | "noFallthroughCasesInSwitch": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ], 32 | "exclude": [ 33 | ".git", 34 | "node_modules" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/@textlint/config-partial-parser/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 2 | 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | .env.test 62 | 63 | # parcel-bundler cache (https://parceljs.org/) 64 | .cache 65 | 66 | # next.js build output 67 | .next 68 | 69 | # nuxt.js build output 70 | .nuxt 71 | 72 | # vuepress build output 73 | .vuepress/dist 74 | 75 | # Serverless directories 76 | .serverless/ 77 | 78 | # FuseBox cache 79 | .fusebox/ 80 | 81 | # DynamoDB Local files 82 | .dynamodb/ 83 | 84 | 85 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 86 | 87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 88 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 89 | 90 | # User-specific stuff 91 | .idea/**/workspace.xml 92 | .idea/**/tasks.xml 93 | .idea/**/usage.statistics.xml 94 | .idea/**/dictionaries 95 | .idea/**/shelf 96 | 97 | # Generated files 98 | .idea/**/contentModel.xml 99 | 100 | # Sensitive or high-churn files 101 | .idea/**/dataSources/ 102 | .idea/**/dataSources.ids 103 | .idea/**/dataSources.local.xml 104 | .idea/**/sqlDataSources.xml 105 | .idea/**/dynamic.xml 106 | .idea/**/uiDesigner.xml 107 | .idea/**/dbnavigator.xml 108 | 109 | # Gradle 110 | .idea/**/gradle.xml 111 | .idea/**/libraries 112 | 113 | # Gradle and Maven with auto-import 114 | # When using Gradle or Maven with auto-import, you should exclude module files, 115 | # since they will be recreated, and may cause churn. Uncomment if using 116 | # auto-import. 117 | # .idea/modules.xml 118 | # .idea/*.iml 119 | # .idea/modules 120 | 121 | # CMake 122 | cmake-build-*/ 123 | 124 | # Mongo Explorer plugin 125 | .idea/**/mongoSettings.xml 126 | 127 | # File-based project format 128 | *.iws 129 | 130 | # IntelliJ 131 | out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Cursive Clojure plugin 140 | .idea/replstate.xml 141 | 142 | # Crashlytics plugin (for Android Studio and IntelliJ) 143 | com_crashlytics_export_strings.xml 144 | crashlytics.properties 145 | crashlytics-build.properties 146 | fabric.properties 147 | 148 | # Editor-based Rest Client 149 | .idea/httpRequests 150 | 151 | # Android studio 3.1+ serialized cache file 152 | .idea/caches/build_file_checksums.ser 153 | 154 | 155 | # Build files 156 | /lib 157 | /module 158 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [0.12.0](https://github.com/textlint/editor/compare/v0.11.3...v0.12.0) (2021-05-24) 7 | 8 | 9 | ### Features 10 | 11 | * **deps:** update to textlint@12 ([#50](https://github.com/textlint/editor/issues/50)) ([a459ba3](https://github.com/textlint/editor/commit/a459ba3962ac853a82b1485f7023b4625f940372)) 12 | 13 | 14 | 15 | 16 | 17 | # [0.11.0](https://github.com/textlint/editor/compare/v0.10.5...v0.11.0) (2021-05-02) 18 | 19 | **Note:** Version bump only for package @textlint/runtime-helper 20 | 21 | 22 | 23 | 24 | 25 | ## [0.10.4](https://github.com/textlint/editor/compare/v0.10.3...v0.10.4) (2021-04-19) 26 | 27 | **Note:** Version bump only for package @textlint/runtime-helper 28 | 29 | 30 | 31 | 32 | 33 | ## [0.10.2](https://github.com/textlint/editor/compare/v0.10.1...v0.10.2) (2021-04-18) 34 | 35 | **Note:** Version bump only for package @textlint/runtime-helper 36 | 37 | 38 | 39 | 40 | 41 | # [0.10.0](https://github.com/textlint/editor/compare/v0.9.3...v0.10.0) (2021-04-18) 42 | 43 | **Note:** Version bump only for package @textlint/runtime-helper 44 | 45 | 46 | 47 | 48 | 49 | # [0.9.0](https://github.com/textlint/editor/compare/v0.8.2...v0.9.0) (2021-04-17) 50 | 51 | 52 | ### Bug Fixes 53 | 54 | * fix hide popup when no hovering item ([d4cbea6](https://github.com/textlint/editor/commit/d4cbea6f44b28ef325a0f7f9d96ef738fa280717)) 55 | * use @kvs/env ([a72c5b5](https://github.com/textlint/editor/commit/a72c5b54b056f52c25e8d2c295f655759b7dd098)) 56 | 57 | 58 | ### Features 59 | 60 | * support "ignore" feature ([ef14d33](https://github.com/textlint/editor/commit/ef14d337c48150d99dd853cac243a988d3244727)) 61 | 62 | 63 | 64 | 65 | 66 | # [0.8.0](https://github.com/textlint/editor/compare/v0.7.1...v0.8.0) (2020-10-27) 67 | 68 | **Note:** Version bump only for package @textlint/runtime-helper 69 | 70 | 71 | 72 | 73 | 74 | # [0.7.0](https://github.com/textlint/editor/compare/v0.6.0...v0.7.0) (2020-08-05) 75 | 76 | **Note:** Version bump only for package @textlint/runtime-helper 77 | 78 | 79 | 80 | 81 | 82 | # [0.6.0](https://github.com/textlint/editor/compare/v0.5.0...v0.6.0) (2020-08-02) 83 | 84 | **Note:** Version bump only for package @textlint/runtime-helper 85 | 86 | 87 | 88 | 89 | 90 | # [0.5.0](https://github.com/textlint/editor/compare/v0.4.2...v0.5.0) (2020-08-02) 91 | 92 | **Note:** Version bump only for package @textlint/runtime-helper 93 | 94 | 95 | 96 | 97 | 98 | # [0.4.0](https://github.com/textlint/editor/compare/v0.3.0...v0.4.0) (2020-08-02) 99 | 100 | **Note:** Version bump only for package @textlint/runtime-helper 101 | 102 | 103 | 104 | 105 | 106 | # [0.3.0](https://github.com/textlint/editor/compare/v0.2.2...v0.3.0) (2020-07-31) 107 | 108 | **Note:** Version bump only for package @textlint/runtime-helper 109 | 110 | 111 | 112 | 113 | 114 | # [0.2.0](https://github.com/textlint/editor/compare/v0.1.2...v0.2.0) (2020-07-30) 115 | 116 | **Note:** Version bump only for package @textlint/runtime-helper 117 | 118 | 119 | 120 | 121 | 122 | ## 0.1.1 (2020-07-29) 123 | 124 | **Note:** Version bump only for package @textlint/runtime-helper 125 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/runtime-helper 2 | 3 | A runtime helper 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/): 8 | 9 | npm install @textlint/runtime-helper 10 | 11 | ## Usage 12 | 13 | - [ ] Write usage instructions 14 | 15 | ## Changelog 16 | 17 | See [Releases page](https://github.com/textlint/editor/releases). 18 | 19 | ## Running tests 20 | 21 | Install devDependencies and Run `npm test`: 22 | 23 | npm test 24 | 25 | ## Contributing 26 | 27 | Pull requests and stars are always welcome. 28 | 29 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 30 | 31 | 1. Fork it! 32 | 2. Create your feature branch: `git checkout -b my-new-feature` 33 | 3. Commit your changes: `git commit -am 'Add some feature'` 34 | 4. Push to the branch: `git push origin my-new-feature` 35 | 5. Submit a pull request :D 36 | 37 | ## Author 38 | 39 | - [github/azu](https://github.com/azu) 40 | - [twitter/azu_re](https://twitter.com/azu_re) 41 | 42 | ## License 43 | 44 | MIT © azu 45 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/runtime-helper", 3 | "version": "0.17.0", 4 | "description": "A runtime helper", 5 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/runtime-helper/", 6 | "bugs": { 7 | "url": "https://github.com/textlint/editor/issues" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/textlint/editor.git" 12 | }, 13 | "license": "MIT", 14 | "author": "azu", 15 | "sideEffects": false, 16 | "main": "lib/index.js", 17 | "module": "module/index.js", 18 | "types": "lib/index.d.ts", 19 | "directories": { 20 | "lib": "lib", 21 | "test": "test" 22 | }, 23 | "files": [ 24 | "bin/", 25 | "lib/", 26 | "module" 27 | ], 28 | "scripts": { 29 | "build": "tsc -p . && tsc --project ./tsconfig.module.json", 30 | "clean": "rimraf lib/ module/", 31 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 32 | "prepublish": "npm run --if-present build", 33 | "watch": "tsc -p . --watch" 34 | }, 35 | "prettier": { 36 | "printWidth": 120, 37 | "singleQuote": false, 38 | "tabWidth": 4, 39 | "trailingComma": "none" 40 | }, 41 | "dependencies": { 42 | "@kvs/env": "^1.1.0", 43 | "@textlint/config-loader": "^14.0.4", 44 | "@textlint/kernel": "^14.0.4", 45 | "@textlint/module-interop": "^14.0.4", 46 | "@textlint/types": "^14.0.4", 47 | "@textlint/utils": "^14.0.4" 48 | }, 49 | "devDependencies": { 50 | "@types/mocha": "^10.0.1", 51 | "@types/node": "^18.13.0", 52 | "mocha": "^10.8.2", 53 | "prettier": "^2.3.0", 54 | "rimraf": "^3.0.2", 55 | "ts-node": "^10.9.1", 56 | "ts-node-test-register": "^10.0.0", 57 | "typescript": "^4.9.5" 58 | }, 59 | "publishConfig": { 60 | "access": "public" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/src/index.ts: -------------------------------------------------------------------------------- 1 | export { presetToKernelRules } from "./preset-to-rule"; 2 | export { openStorage } from "./worker-cache"; 3 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/src/preset-to-rule.ts: -------------------------------------------------------------------------------- 1 | // Preset to kernel rule 2 | import type { TextlintConfigRulePreset } from "@textlint/config-loader"; 3 | import type { TextlintKernelRule } from "@textlint/kernel"; 4 | import { normalizeTextlintPresetSubRuleKey } from "@textlint/utils"; 5 | 6 | export const presetToKernelRules = ( 7 | preset: TextlintConfigRulePreset["preset"], 8 | presetId: TextlintConfigRulePreset["id"] 9 | ): TextlintKernelRule[] => { 10 | const presetRules = preset.rules; 11 | return Object.keys(presetRules).map((ruleId) => { 12 | const normalizedKey = normalizeTextlintPresetSubRuleKey({ preset: presetId, rule: ruleId }); 13 | return { 14 | ruleId: normalizedKey, 15 | rule: preset.rules[ruleId], 16 | options: preset.rulesConfig[ruleId] 17 | }; 18 | }); 19 | }; 20 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/src/worker-cache.ts: -------------------------------------------------------------------------------- 1 | import { kvsEnvStorage } from "@kvs/env"; 2 | 3 | /** 4 | * Simple KVS on WebWorker 5 | * @param dbName 6 | */ 7 | export async function openStorage(dbName: string) { 8 | const storage = await kvsEnvStorage({ 9 | version: 1, 10 | name: "@textlint/runtime-helper" 11 | }); 12 | return { 13 | get(key: string): Promise { 14 | return storage.get(dbName + "::" + key); 15 | }, 16 | async set(key: string, value: V): Promise { 17 | await storage.set(dbName + "::" + key, value); 18 | return; 19 | }, 20 | clear(): Promise { 21 | return storage.clear(); 22 | } 23 | }; 24 | } 25 | -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "es5", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "lib": [ 14 | "esnext", 15 | "dom" 16 | ], 17 | /* Strict Type-Checking Options */ 18 | "strict": true, 19 | /* Additional Checks */ 20 | /* Report errors on unused locals. */ 21 | "noUnusedLocals": true, 22 | /* Report errors on unused parameters. */ 23 | "noUnusedParameters": true, 24 | /* Report error when not all code paths in function return a value. */ 25 | "noImplicitReturns": true, 26 | /* Report errors for fallthrough cases in switch statement. */ 27 | "noFallthroughCasesInSwitch": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ], 32 | "exclude": [ 33 | ".git", 34 | "node_modules" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/@textlint/runtime-helper/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 2 | example/textlint-worker.js 3 | # Logs 4 | logs 5 | *.log 6 | npm-debug.log* 7 | yarn-debug.log* 8 | yarn-error.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # Bower dependency directory (https://bower.io/) 29 | bower_components 30 | 31 | # node-waf configuration 32 | .lock-wscript 33 | 34 | # Compiled binary addons (https://nodejs.org/api/addons.html) 35 | build/Release 36 | 37 | # Dependency directories 38 | node_modules/ 39 | jspm_packages/ 40 | 41 | # TypeScript v1 declaration files 42 | typings/ 43 | 44 | # Optional npm cache directory 45 | .npm 46 | 47 | # Optional eslint cache 48 | .eslintcache 49 | 50 | # Optional REPL history 51 | .node_repl_history 52 | 53 | # Output of 'npm pack' 54 | *.tgz 55 | 56 | # Yarn Integrity file 57 | .yarn-integrity 58 | 59 | # dotenv environment variables file 60 | .env 61 | .env.test 62 | 63 | # parcel-bundler cache (https://parceljs.org/) 64 | .cache 65 | 66 | # next.js build output 67 | .next 68 | 69 | # nuxt.js build output 70 | .nuxt 71 | 72 | # vuepress build output 73 | .vuepress/dist 74 | 75 | # Serverless directories 76 | .serverless/ 77 | 78 | # FuseBox cache 79 | .fusebox/ 80 | 81 | # DynamoDB Local files 82 | .dynamodb/ 83 | 84 | 85 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 86 | 87 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 88 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 89 | 90 | # User-specific stuff 91 | .idea/**/workspace.xml 92 | .idea/**/tasks.xml 93 | .idea/**/usage.statistics.xml 94 | .idea/**/dictionaries 95 | .idea/**/shelf 96 | 97 | # Generated files 98 | .idea/**/contentModel.xml 99 | 100 | # Sensitive or high-churn files 101 | .idea/**/dataSources/ 102 | .idea/**/dataSources.ids 103 | .idea/**/dataSources.local.xml 104 | .idea/**/sqlDataSources.xml 105 | .idea/**/dynamic.xml 106 | .idea/**/uiDesigner.xml 107 | .idea/**/dbnavigator.xml 108 | 109 | # Gradle 110 | .idea/**/gradle.xml 111 | .idea/**/libraries 112 | 113 | # Gradle and Maven with auto-import 114 | # When using Gradle or Maven with auto-import, you should exclude module files, 115 | # since they will be recreated, and may cause churn. Uncomment if using 116 | # auto-import. 117 | # .idea/modules.xml 118 | # .idea/*.iml 119 | # .idea/modules 120 | 121 | # CMake 122 | cmake-build-*/ 123 | 124 | # Mongo Explorer plugin 125 | .idea/**/mongoSettings.xml 126 | 127 | # File-based project format 128 | *.iws 129 | 130 | # IntelliJ 131 | out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Cursive Clojure plugin 140 | .idea/replstate.xml 141 | 142 | # Crashlytics plugin (for Android Studio and IntelliJ) 143 | com_crashlytics_export_strings.xml 144 | crashlytics.properties 145 | crashlytics-build.properties 146 | fabric.properties 147 | 148 | # Editor-based Rest Client 149 | .idea/httpRequests 150 | 151 | # Android studio 3.1+ serialized cache file 152 | .idea/caches/build_file_checksums.ser 153 | 154 | 155 | # Build files 156 | /lib 157 | /module 158 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/.textlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "no-dropping-the-ra": true, 4 | "preset-ja-technical-writing": true, 5 | "prh": { 6 | "rulePaths": [ 7 | "./prh.yml" 8 | ] 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/script-compiler 2 | 3 | textlint compiler tool 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/): 8 | 9 | npm install @textlint/script-compiler 10 | 11 | ## Usage 12 | 13 | Usage 14 | $ textlint-script-compiler 15 | 16 | Options 17 | --cwd [path:String] current working directory 18 | --textlintrc [path:String] path to .textlintrc file. 19 | Default: .textlintrc.{json,yaml,js} 20 | --output-dir [path:String] output file path that is written of reported result. 21 | --mode [String] build mode: "production" or "development" 22 | 23 | Metadata Options 24 | 25 | Metadata is inferred from package.json by default. 26 | If you want to set metadata by manually, please use these flags. 27 | 28 | --metadataName [String] generated script name 29 | --metadataNamespace [String] generated script namespace 30 | --metadataHomepage [String] generated script homepage url 31 | --metadataVersion [String] generated script version 32 | 33 | Examples 34 | $ textlint-script-compiler --output-dir ./dist --metadataName "test" --metadataNamespace "https://example.com" 35 | 36 | ## Demo 37 | 38 | yarn run compile:textlint 39 | yarn dev 40 | 41 | ## Command 42 | 43 | ```js 44 | const worker = new Worker('textlint.js'); 45 | worker.addEventListener('message', function (event) { 46 | if (event.data.command === "init") { 47 | // override user config 48 | worker.postMessage({ 49 | command: "merge-config", 50 | textlintrc: { 51 | "rules": { 52 | "preset-ja-technical-writing": { 53 | "sentence-length": { 54 | "max": 5 55 | } 56 | } 57 | } 58 | }, 59 | }); 60 | const id = crypto.randomUUID(); 61 | setTimeout(() => { 62 | // lint 63 | worker.postMessage({ 64 | id, 65 | command: "lint", 66 | text: "お刺身が食べれない", 67 | ext: ".md" 68 | }) 69 | }) 70 | } else if (event.data.command === "lint:result") { 71 | // receive lint result 72 | console.log(event.data.result); 73 | console.timeEnd("lint") 74 | } 75 | }); 76 | ``` 77 | ## Changelog 78 | 79 | See [Releases page](https://github.com/textlint/editor/releases). 80 | 81 | ## Running tests 82 | 83 | Install devDependencies and Run `npm test`: 84 | 85 | npm test 86 | 87 | ## Contributing 88 | 89 | Pull requests and stars are always welcome. 90 | 91 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 92 | 93 | 1. Fork it! 94 | 2. Create your feature branch: `git checkout -b my-new-feature` 95 | 3. Commit your changes: `git commit -am 'Add some feature'` 96 | 4. Push to the branch: `git push origin my-new-feature` 97 | 5. Submit a pull request :D 98 | 99 | ## Author 100 | 101 | - [github/azu](https://github.com/azu) 102 | - [twitter/azu_re](https://twitter.com/azu_re) 103 | 104 | ## License 105 | 106 | MIT © azu 107 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/bin/cmd.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require("../lib/cli") 3 | .run() 4 | .then( 5 | ({ exitStatus, stderr, stdout }) => { 6 | if (stdout) { 7 | console.log(stdout); 8 | } 9 | if (stderr) { 10 | console.error(stderr); 11 | } 12 | process.exit(exitStatus); 13 | }, 14 | (error) => { 15 | console.error(error); 16 | process.exit(1); 17 | } 18 | ); 19 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/example/load-meta.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs/promises"); 2 | const maxBuffer = 1024 * 10; 3 | const buffer = Buffer.alloc(maxBuffer); 4 | (async function () { 5 | const fd = await fs.open(__dirname + "/textlint.js", "r"); 6 | const r = await fd.read(buffer, 0, maxBuffer); 7 | const metadataPattenr = /\/*! textlinteditor: (.*)\*\//; 8 | const match = String(r.buffer).match(metadataPattenr); 9 | if (!match) { 10 | throw new Error("Can not read metadata"); 11 | } 12 | console.log(JSON.parse(match[1])) 13 | })() 14 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/example/webindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | worker 6 | 7 | 8 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/script-compiler", 3 | "version": "0.17.0", 4 | "description": "textlint script compiler tool", 5 | "keywords": [ 6 | "textlint", 7 | "webpack", 8 | "bundler", 9 | "compiler" 10 | ], 11 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/script-compiler/", 12 | "bugs": { 13 | "url": "https://github.com/textlint/editor/issues" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "https://github.com/textlint/editor.git" 18 | }, 19 | "license": "MIT", 20 | "author": "azu", 21 | "sideEffects": false, 22 | "main": "lib/index.js", 23 | "module": "module/index.js", 24 | "types": "lib/index.d.ts", 25 | "directories": { 26 | "lib": "lib", 27 | "test": "test" 28 | }, 29 | "bin": { 30 | "textlint-script-compiler": "./bin/cmd.js" 31 | }, 32 | "files": [ 33 | "bin/", 34 | "lib/", 35 | "module/", 36 | "patch/" 37 | ], 38 | "scripts": { 39 | "build": "tsc -p . && tsc --project ./tsconfig.module.json", 40 | "clean": "rimraf lib/ module/", 41 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 42 | "prepublish": "npm run --if-present build", 43 | "test": "npm run build:example", 44 | "watch": "tsc -p . --watch", 45 | "prebuild:example": "npm run build", 46 | "build:example": "node ./bin/cmd.js --outputDir ./example/ --metadataName test --metadataNamespace example.com" 47 | }, 48 | "prettier": { 49 | "printWidth": 120, 50 | "singleQuote": false, 51 | "tabWidth": 4, 52 | "trailingComma": "none" 53 | }, 54 | "dependencies": { 55 | "@babel/core": "^7.12.10", 56 | "@textlint/config-inliner": "^0.17.0", 57 | "@textlint/config-loader": "^14.0.4", 58 | "@textlint/config-partial-parser": "^0.17.0", 59 | "@textlint/kernel": "^14.0.4", 60 | "@textlint/runtime-helper": "^0.17.0", 61 | "@textlint/script-parser": "^0.17.0", 62 | "@textlint/textlint-plugin-markdown": "^14.0.4", 63 | "@textlint/textlint-plugin-text": "^14.0.4", 64 | "@textlint/types": "^14.0.4", 65 | "babel-loader": "^8.2.2", 66 | "babel-plugin-static-fs": "^3.0.0", 67 | "meow": "^9.0.0", 68 | "node-polyfill-webpack-plugin": "^2.0.1", 69 | "read-pkg": "^5.2.0", 70 | "rimraf": "^3.0.2", 71 | "terser-webpack-plugin": "^5.3.6", 72 | "webpack": "^5.91.0" 73 | }, 74 | "devDependencies": { 75 | "@types/mocha": "^10.0.1", 76 | "@types/node": "^18.13.0", 77 | "@types/webpack": "^5.28.5", 78 | "mocha": "^10.8.2", 79 | "prettier": "^2.3.0", 80 | "textlint-rule-no-dropping-the-ra": "^3.0.0", 81 | "textlint-rule-preset-ja-technical-writing": "^6.0.0", 82 | "textlint-rule-prh": "^6.0.0", 83 | "ts-node": "^10.9.1", 84 | "ts-node-test-register": "^10.0.0", 85 | "typescript": "^4.9.5" 86 | }, 87 | "publishConfig": { 88 | "access": "public" 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/patch/README.md: -------------------------------------------------------------------------------- 1 | # patch file 2 | 3 | ## kuromoji.js 4 | 5 | - Add Cache 6 | - Fix url loading bug 7 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/patch/kuromoji.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 Takuya Asano 3 | * Copyright 2010-2014 Atilika Inc. and contributors 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | "use strict"; 19 | const { openStorage } = require("@textlint/runtime-helper"); 20 | var zlib = require("zlibjs/bin/gunzip.min.js"); 21 | var DictionaryLoader = require("kuromoji/src/loader/DictionaryLoader"); 22 | //=== Modify kuromoji.js's browser loader 23 | const urlMap = new Map(); 24 | class Deferred { 25 | constructor() { 26 | this.promise = new Promise((resolve, reject) => { 27 | this.resolve = resolve; 28 | this.reject = reject; 29 | }); 30 | } 31 | } 32 | /** 33 | * BrowserDictionaryLoader inherits DictionaryLoader, using jQuery XHR for download 34 | * @param {string} dic_path Dictionary path 35 | * @constructor 36 | */ 37 | function BrowserDictionaryLoader(dic_path) { 38 | DictionaryLoader.apply(this, [dic_path]); 39 | } 40 | 41 | BrowserDictionaryLoader.prototype = Object.create(DictionaryLoader.prototype); 42 | 43 | /** 44 | * Utility function to load gzipped dictionary 45 | * @param {string} url Dictionary URL 46 | * @param {BrowserDictionaryLoader~onLoad} callback Callback function 47 | */ 48 | BrowserDictionaryLoader.prototype.loadArrayBuffer = async function (url, callback) { 49 | // https://github.com/takuyaa/kuromoji.js/issues/37 50 | const fixedURL = url.replace("https:/", "https://"); 51 | const dictionaryStorage = await openStorage("kuromoji"); 52 | const cachedDictBuffer = await dictionaryStorage.get(fixedURL); 53 | if (cachedDictBuffer) { 54 | // console.log("return cache", cachedDictBuffer); 55 | return callback(null, cachedDictBuffer); 56 | } 57 | // Suppress multiple request to same url at same time 58 | if (urlMap.has(fixedURL)) { 59 | return urlMap 60 | .get(fixedURL) 61 | .promise.then((result) => { 62 | callback(null, result); 63 | }) 64 | .catch((error) => { 65 | callback(error); 66 | }); 67 | } 68 | const deferred = new Deferred(); 69 | urlMap.set(fixedURL, deferred); 70 | fetch(fixedURL) 71 | .then(function (response) { 72 | if (!response.ok) { 73 | return callback(response.statusText, null); 74 | } 75 | response.arrayBuffer().then(function (arraybuffer) { 76 | var gz = new zlib.Zlib.Gunzip(new Uint8Array(arraybuffer)); 77 | var typed_array = gz.decompress(); 78 | return dictionaryStorage.set(fixedURL, typed_array.buffer).then(() => { 79 | // console.log("cached", fixedURL); 80 | deferred.resolve(typed_array.buffer); 81 | callback(null, typed_array.buffer); 82 | }); 83 | }); 84 | }) 85 | .catch(function (exception) { 86 | deferred.reject(exception); 87 | callback(exception, null); 88 | }); 89 | }; 90 | /** 91 | * Callback 92 | * @callback BrowserDictionaryLoader~onLoad 93 | * @param {Object} err Error object 94 | * @param {Uint8Array} buffer Loaded buffer 95 | */ 96 | 97 | module.exports = BrowserDictionaryLoader; 98 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/prh.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | rules: 3 | - expected: jQuery 4 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/src/CodeGenerator/API.ts: -------------------------------------------------------------------------------- 1 | import type { TextlintFixResult, TextlintMessage, TextlintResult } from "@textlint/types"; 2 | 3 | /** 4 | * textlint Server API 5 | */ 6 | export type API = { 7 | lint({ text, ext }: { text: string; ext: string }): TextlintResult[]; 8 | // fix all text with all rule 9 | fixAll({ text, ext }: { text: string; ext: string }): TextlintFixResult; 10 | // fix all with a rule 11 | fixRule({ text, ext, message }: { text: string; ext: string; message: TextlintMessage }): TextlintFixResult; 12 | // fix the text 13 | fixText({ text, ext, message }: { text: string; ext: string; message: TextlintMessage }): { output: string }; 14 | }; 15 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/src/CodeGenerator/CodeGeneraterOptions.ts: -------------------------------------------------------------------------------- 1 | export type CodeGeneraterOptions = { 2 | cwd?: string; 3 | configFilePath?: string; 4 | }; 5 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/src/cli.ts: -------------------------------------------------------------------------------- 1 | import meow from "meow"; 2 | import { compile, validateTextlintScriptMetadata } from "./compiler"; 3 | import path from "path"; 4 | import readPkg from "read-pkg"; 5 | 6 | export const cli = meow( 7 | ` 8 | Usage 9 | $ textlint-script-compiler 10 | 11 | Options 12 | --cwd [path:String] current working directory 13 | --textlintrc [path:String] path to .textlintrc file. 14 | Default: .textlintrc.{json,yaml,js} 15 | --output-dir [path:String] output file path that is written of reported result. 16 | --mode [String] build mode: "production" or "development" 17 | 18 | Metadata Options 19 | 20 | Metadata is inferred from package.json by default. 21 | If you want to set metadata by manually, please use these flags. 22 | 23 | --metadataName [String] generated script name 24 | --metadataNamespace [String] generated script namespace 25 | --metadataHomepage [String] generated script homepage url 26 | --metadataVersion [String] generated script version 27 | 28 | Examples 29 | $ textlint-script-compiler --output-dir ./dist --metadataName "test" --metadataNamespace "https://example.com" 30 | `, 31 | { 32 | flags: { 33 | outputDir: { 34 | type: "string", 35 | isRequired: true 36 | }, 37 | textlintrc: { 38 | type: "string" 39 | }, 40 | compileTarget: { 41 | type: "string", 42 | default: "webworker" 43 | }, 44 | mode: { 45 | type: "string", 46 | default: "production" 47 | }, 48 | metadataName: { 49 | type: "string" 50 | }, 51 | metadataNamespace: { 52 | type: "string" 53 | }, 54 | metadataHomepage: { 55 | type: "string" 56 | }, 57 | metadataVersion: { 58 | type: "string" 59 | }, 60 | // DEBUG option 61 | cwd: { 62 | type: "string", 63 | default: process.cwd() 64 | }, 65 | debug: { 66 | type: "boolean", 67 | default: false 68 | } 69 | }, 70 | autoHelp: true, 71 | autoVersion: true 72 | } 73 | ); 74 | 75 | export const run = async ( 76 | _input = cli.input, 77 | flags = cli.flags 78 | ): Promise<{ exitStatus: number; stdout: string | null; stderr: Error | null }> => { 79 | const pkg = await readPkg({ 80 | cwd: flags.cwd 81 | }); 82 | const metadata = { 83 | name: pkg.name ?? flags["metadataName"], 84 | namespace: pkg.homepage ?? flags["metadataNamespace"], 85 | homepage: pkg.homepage ?? flags["metadataHomepage"], 86 | version: pkg.version ?? flags["metadataVersion"] 87 | }; 88 | // assert 89 | validateTextlintScriptMetadata(metadata); 90 | return compile({ 91 | configFilePath: flags.textlintrc, 92 | cwd: flags.cwd, 93 | compileTarget: flags.compileTarget as "webworker", 94 | outputDir: path.join(flags.cwd, flags.outputDir), 95 | mode: flags.mode as "production" | "development", 96 | metadata: metadata 97 | }) 98 | .then(() => { 99 | return { 100 | exitStatus: 0, 101 | stdout: null, 102 | stderr: null 103 | }; 104 | }) 105 | .catch((error) => { 106 | return { 107 | exitStatus: 1, 108 | stderr: null, 109 | stdout: error 110 | }; 111 | }); 112 | }; 113 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/src/index.ts: -------------------------------------------------------------------------------- 1 | export { createWebpackConfig, compile, compileOptions, validateTextlintScriptMetadata } from "./compiler"; 2 | // TODO: move to separate package 3 | export type { 4 | TextlintWorkerCommand, 5 | TextlintWorkerCommandResponse, 6 | TextlintWorkerCommandMergeConfig, 7 | TextlintWorkerCommandFix, 8 | TextlintWorkerCommandLint, 9 | TextlintWorkerCommandResponseFix, 10 | TextlintWorkerCommandResponseInit, 11 | TextlintWorkerCommandResponseLint, 12 | TextlintWorkerCommandResponseError 13 | } from "./CodeGenerator/worker-codegen"; 14 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "ES2015", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "skipLibCheck": true, 14 | "lib": [ 15 | "esnext", 16 | "dom" 17 | ], 18 | /* Strict Type-Checking Options */ 19 | "strict": true, 20 | /* Additional Checks */ 21 | /* Report errors on unused locals. */ 22 | "noUnusedLocals": true, 23 | /* Report errors on unused parameters. */ 24 | "noUnusedParameters": true, 25 | /* Report error when not all code paths in function return a value. */ 26 | "noImplicitReturns": true, 27 | /* Report errors for fallthrough cases in switch statement. */ 28 | "noFallthroughCasesInSwitch": true 29 | }, 30 | "include": [ 31 | "src/**/*" 32 | ], 33 | "exclude": [ 34 | ".git", 35 | "node_modules" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /packages/@textlint/script-compiler/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/@textlint/script-parser/.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 2 | # Logs 3 | logs 4 | *.log 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | 9 | # Runtime data 10 | pids 11 | *.pid 12 | *.seed 13 | *.pid.lock 14 | 15 | # Directory for instrumented libs generated by jscoverage/JSCover 16 | lib-cov 17 | 18 | # Coverage directory used by tools like istanbul 19 | coverage 20 | 21 | # nyc test coverage 22 | .nyc_output 23 | 24 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 25 | .grunt 26 | 27 | # Bower dependency directory (https://bower.io/) 28 | bower_components 29 | 30 | # node-waf configuration 31 | .lock-wscript 32 | 33 | # Compiled binary addons (https://nodejs.org/api/addons.html) 34 | build/Release 35 | 36 | # Dependency directories 37 | node_modules/ 38 | jspm_packages/ 39 | 40 | # TypeScript v1 declaration files 41 | typings/ 42 | 43 | # Optional npm cache directory 44 | .npm 45 | 46 | # Optional eslint cache 47 | .eslintcache 48 | 49 | # Optional REPL history 50 | .node_repl_history 51 | 52 | # Output of 'npm pack' 53 | *.tgz 54 | 55 | # Yarn Integrity file 56 | .yarn-integrity 57 | 58 | # dotenv environment variables file 59 | .env 60 | .env.test 61 | 62 | # parcel-bundler cache (https://parceljs.org/) 63 | .cache 64 | 65 | # next.js build output 66 | .next 67 | 68 | # nuxt.js build output 69 | .nuxt 70 | 71 | # vuepress build output 72 | .vuepress/dist 73 | 74 | # Serverless directories 75 | .serverless/ 76 | 77 | # FuseBox cache 78 | .fusebox/ 79 | 80 | # DynamoDB Local files 81 | .dynamodb/ 82 | 83 | 84 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 85 | 86 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 87 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 88 | 89 | # User-specific stuff 90 | .idea/**/workspace.xml 91 | .idea/**/tasks.xml 92 | .idea/**/usage.statistics.xml 93 | .idea/**/dictionaries 94 | .idea/**/shelf 95 | 96 | # Generated files 97 | .idea/**/contentModel.xml 98 | 99 | # Sensitive or high-churn files 100 | .idea/**/dataSources/ 101 | .idea/**/dataSources.ids 102 | .idea/**/dataSources.local.xml 103 | .idea/**/sqlDataSources.xml 104 | .idea/**/dynamic.xml 105 | .idea/**/uiDesigner.xml 106 | .idea/**/dbnavigator.xml 107 | 108 | # Gradle 109 | .idea/**/gradle.xml 110 | .idea/**/libraries 111 | 112 | # Gradle and Maven with auto-import 113 | # When using Gradle or Maven with auto-import, you should exclude module files, 114 | # since they will be recreated, and may cause churn. Uncomment if using 115 | # auto-import. 116 | # .idea/modules.xml 117 | # .idea/*.iml 118 | # .idea/modules 119 | 120 | # CMake 121 | cmake-build-*/ 122 | 123 | # Mongo Explorer plugin 124 | .idea/**/mongoSettings.xml 125 | 126 | # File-based project format 127 | *.iws 128 | 129 | # IntelliJ 130 | out/ 131 | 132 | # mpeltonen/sbt-idea plugin 133 | .idea_modules/ 134 | 135 | # JIRA plugin 136 | atlassian-ide-plugin.xml 137 | 138 | # Cursive Clojure plugin 139 | .idea/replstate.xml 140 | 141 | # Crashlytics plugin (for Android Studio and IntelliJ) 142 | com_crashlytics_export_strings.xml 143 | crashlytics.properties 144 | crashlytics-build.properties 145 | fabric.properties 146 | 147 | # Editor-based Rest Client 148 | .idea/httpRequests 149 | 150 | # Android studio 3.1+ serialized cache file 151 | .idea/caches/build_file_checksums.ser 152 | 153 | 154 | # Build files 155 | /lib 156 | /module 157 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/script-parser/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | # [0.12.0](https://github.com/textlint/editor/compare/v0.11.3...v0.12.0) (2021-05-24) 7 | 8 | 9 | ### Features 10 | 11 | * **deps:** update to textlint@12 ([#50](https://github.com/textlint/editor/issues/50)) ([a459ba3](https://github.com/textlint/editor/commit/a459ba3962ac853a82b1485f7023b4625f940372)) 12 | 13 | 14 | 15 | 16 | 17 | # [0.11.0](https://github.com/textlint/editor/compare/v0.10.5...v0.11.0) (2021-05-02) 18 | 19 | **Note:** Version bump only for package @textlint/script-parser 20 | 21 | 22 | 23 | 24 | 25 | ## [0.10.4](https://github.com/textlint/editor/compare/v0.10.3...v0.10.4) (2021-04-19) 26 | 27 | **Note:** Version bump only for package @textlint/script-parser 28 | 29 | 30 | 31 | 32 | 33 | ## [0.10.2](https://github.com/textlint/editor/compare/v0.10.1...v0.10.2) (2021-04-18) 34 | 35 | **Note:** Version bump only for package @textlint/script-parser 36 | 37 | 38 | 39 | 40 | 41 | # [0.10.0](https://github.com/textlint/editor/compare/v0.9.3...v0.10.0) (2021-04-18) 42 | 43 | 44 | ### Bug Fixes 45 | 46 | * **script-parser:** fix script banner format ([166694c](https://github.com/textlint/editor/commit/166694cc50853e67631ab07833a525b219f9985c)) 47 | 48 | 49 | 50 | 51 | 52 | # [0.9.0](https://github.com/textlint/editor/compare/v0.8.2...v0.9.0) (2021-04-17) 53 | 54 | 55 | ### Features 56 | 57 | * support "ignore" feature ([ef14d33](https://github.com/textlint/editor/commit/ef14d337c48150d99dd853cac243a988d3244727)) 58 | 59 | 60 | 61 | 62 | 63 | # [0.8.0](https://github.com/textlint/editor/compare/v0.7.1...v0.8.0) (2020-10-27) 64 | 65 | 66 | ### Features 67 | 68 | * config update support ([7ffa985](https://github.com/textlint/editor/commit/7ffa985deb20eb3f0f4bb6551f10fd7b20dedc41)) 69 | * design install ([df2f71e](https://github.com/textlint/editor/commit/df2f71e2637b7ac3defba66ce803eba4b5491f5d)) 70 | 71 | 72 | 73 | 74 | 75 | # [0.7.0](https://github.com/textlint/editor/compare/v0.6.0...v0.7.0) (2020-08-05) 76 | 77 | 78 | ### Features 79 | 80 | * add textlint-script-parser ([6a746fb](https://github.com/textlint/editor/commit/6a746fb879a5b4961d37d6f9fd4bfd8bd6286028)) 81 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/script-parser 2 | 3 | A parser for textlint script 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/): 8 | 9 | npm install @textlint/script-parser 10 | 11 | ## Usage 12 | 13 | `textlintScriptContent` should includes `/**! textlint: JSONstring */`; 14 | 15 | ```ts 16 | import { parseMetadata } from "@textlint/script-parser"; 17 | 18 | const scriptContent = `/*! textlinteditor: {"name":"example","namespace":"https://github.com/textlint/editor","config":{"rules":{"preset-ja-technical-writing":true},"plugins":{"@textlint/text":true,"@textlint/markdown":true}}} */ 19 | self.textlint=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=465)}([function(e,t,n){"use strict";(function(t){var r=n(37);`; 20 | const metadata = parseMetadata(scriptContent); 21 | assert.deepStrictEqual(metadata, { 22 | name: "example", 23 | namespace: "https://github.com/textlint/editor", 24 | config: { 25 | rules: { "preset-ja-technical-writing": true }, 26 | plugins: { "@textlint/text": true, "@textlint/markdown": true } 27 | } 28 | }); 29 | ``` 30 | 31 | ## Changelog 32 | 33 | See [Releases page](https://github.com/textlint/editor/releases). 34 | 35 | ## Running tests 36 | 37 | Install devDependencies and Run `npm test`: 38 | 39 | npm test 40 | 41 | ## Contributing 42 | 43 | Pull requests and stars are always welcome. 44 | 45 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 46 | 47 | 1. Fork it! 48 | 2. Create your feature branch: `git checkout -b my-new-feature` 49 | 3. Commit your changes: `git commit -am 'Add some feature'` 50 | 4. Push to the branch: `git push origin my-new-feature` 51 | 5. Submit a pull request :D 52 | 53 | ## Author 54 | 55 | - [github/azu](https://github.com/azu) 56 | - [twitter/azu_re](https://twitter.com/azu_re) 57 | 58 | ## License 59 | 60 | MIT © azu 61 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/script-parser", 3 | "version": "0.17.0", 4 | "description": "A parser for textlint script", 5 | "keywords": [ 6 | "textlint" 7 | ], 8 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/script-parser/", 9 | "bugs": { 10 | "url": "https://github.com/textlint/editor/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/textlint/editor.git" 15 | }, 16 | "license": "MIT", 17 | "author": "azu", 18 | "sideEffects": false, 19 | "main": "lib/script-parser.js", 20 | "module": "module/script-parser.js", 21 | "types": "lib/script-parser.d.ts", 22 | "directories": { 23 | "lib": "lib", 24 | "test": "test" 25 | }, 26 | "files": [ 27 | "bin/", 28 | "lib/", 29 | "module" 30 | ], 31 | "scripts": { 32 | "build": "tsc -p . && tsc --project ./tsconfig.module.json", 33 | "clean": "rimraf lib/ module/", 34 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 35 | "prepublish": "npm run --if-present build", 36 | "test": "mocha \"test/**/*.ts\"", 37 | "watch": "tsc -p . --watch" 38 | }, 39 | "prettier": { 40 | "printWidth": 120, 41 | "singleQuote": false, 42 | "tabWidth": 4, 43 | "trailingComma": "none" 44 | }, 45 | "devDependencies": { 46 | "@types/mocha": "^10.0.1", 47 | "@types/node": "^18.13.0", 48 | "mocha": "^10.8.2", 49 | "prettier": "^2.3.0", 50 | "rimraf": "^3.0.2", 51 | "ts-node": "^10.9.1", 52 | "ts-node-test-register": "^10.0.0", 53 | "typescript": "^4.9.5" 54 | }, 55 | "publishConfig": { 56 | "access": "public" 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/src/script-parser.ts: -------------------------------------------------------------------------------- 1 | export type TextlintRcConfig = { 2 | plugins?: 3 | | string[] 4 | | { 5 | [index: string]: boolean | {}; 6 | }; 7 | filters?: { 8 | [index: string]: boolean | {}; 9 | }; 10 | rules?: { 11 | [index: string]: boolean | {}; 12 | }; 13 | }; 14 | 15 | export type TextlintScriptMetadata = { 16 | name: string; 17 | namespace: string; 18 | homepage: string; 19 | version: string; 20 | config: TextlintRcConfig; 21 | }; 22 | export type TextlintScriptParseResult = { 23 | metadata: TextlintScriptMetadata; 24 | }; 25 | export const parseMetadata = (scriptContent: string): TextlintScriptMetadata => { 26 | const metadataPattern = /\/*! textlinteditor:@@@ (.*) @@@\s*\*\//; 27 | const match = scriptContent.match(metadataPattern); 28 | if (!match) { 29 | throw new Error("Can not read metadata"); 30 | } 31 | try { 32 | return JSON.parse(match[1]); 33 | } catch (error) { 34 | console.error(error); 35 | throw new Error("Can not parse metadata. It should be JSON format."); 36 | } 37 | }; 38 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/test/script-parser.test.ts: -------------------------------------------------------------------------------- 1 | import assert from "assert"; 2 | import { parseMetadata } from "../src/script-parser"; 3 | 4 | describe("script-parser", function () { 5 | it("should parse comment", () => { 6 | const scriptContent = `/*! textlinteditor:@@@ {"name":"example","namespace":"https://github.com/textlint/editor","config":{"rules":{"preset-ja-technical-writing":true},"plugins":{"@textlint/text":true,"@textlint/markdown":true}}} @@@ */ 7 | self.textlint=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=465)}([function(e,t,n){"use strict";(function(t){var r=n(37);`; 8 | const metadata = parseMetadata(scriptContent); 9 | assert.deepStrictEqual(metadata, { 10 | name: "example", 11 | namespace: "https://github.com/textlint/editor", 12 | config: { 13 | rules: { "preset-ja-technical-writing": true }, 14 | plugins: { "@textlint/text": true, "@textlint/markdown": true } 15 | } 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /packages/@textlint/script-parser/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/script-parser/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "es5", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "lib": [ 14 | "esnext", 15 | "dom" 16 | ], 17 | /* Strict Type-Checking Options */ 18 | "strict": true, 19 | /* Additional Checks */ 20 | /* Report errors on unused locals. */ 21 | "noUnusedLocals": true, 22 | /* Report errors on unused parameters. */ 23 | "noUnusedParameters": true, 24 | /* Report error when not all code paths in function return a value. */ 25 | "noImplicitReturns": true, 26 | /* Report errors for fallthrough cases in switch statement. */ 27 | "noFallthroughCasesInSwitch": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ], 32 | "exclude": [ 33 | ".git", 34 | "node_modules" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/@textlint/script-parser/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/@textlint/website-generator/.gitignore: -------------------------------------------------------------------------------- 1 | # template 2 | template/index.html 3 | template/textchecker-element.esm.js 4 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | 24 | # nyc test coverage 25 | .nyc_output 26 | 27 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 28 | .grunt 29 | 30 | # Bower dependency directory (https://bower.io/) 31 | bower_components 32 | 33 | # node-waf configuration 34 | .lock-wscript 35 | 36 | # Compiled binary addons (https://nodejs.org/api/addons.html) 37 | build/Release 38 | 39 | # Dependency directories 40 | node_modules/ 41 | jspm_packages/ 42 | 43 | # TypeScript v1 declaration files 44 | typings/ 45 | 46 | # Optional npm cache directory 47 | .npm 48 | 49 | # Optional eslint cache 50 | .eslintcache 51 | 52 | # Optional REPL history 53 | .node_repl_history 54 | 55 | # Output of 'npm pack' 56 | *.tgz 57 | 58 | # Yarn Integrity file 59 | .yarn-integrity 60 | 61 | # dotenv environment variables file 62 | .env 63 | .env.test 64 | 65 | # parcel-bundler cache (https://parceljs.org/) 66 | .cache 67 | 68 | # next.js build output 69 | .next 70 | 71 | # nuxt.js build output 72 | .nuxt 73 | 74 | # vuepress build output 75 | .vuepress/dist 76 | 77 | # Serverless directories 78 | .serverless/ 79 | 80 | # FuseBox cache 81 | .fusebox/ 82 | 83 | # DynamoDB Local files 84 | .dynamodb/ 85 | 86 | 87 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 88 | 89 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 90 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 91 | 92 | # User-specific stuff 93 | .idea/**/workspace.xml 94 | .idea/**/tasks.xml 95 | .idea/**/usage.statistics.xml 96 | .idea/**/dictionaries 97 | .idea/**/shelf 98 | 99 | # Generated files 100 | .idea/**/contentModel.xml 101 | 102 | # Sensitive or high-churn files 103 | .idea/**/dataSources/ 104 | .idea/**/dataSources.ids 105 | .idea/**/dataSources.local.xml 106 | .idea/**/sqlDataSources.xml 107 | .idea/**/dynamic.xml 108 | .idea/**/uiDesigner.xml 109 | .idea/**/dbnavigator.xml 110 | 111 | # Gradle 112 | .idea/**/gradle.xml 113 | .idea/**/libraries 114 | 115 | # Gradle and Maven with auto-import 116 | # When using Gradle or Maven with auto-import, you should exclude module files, 117 | # since they will be recreated, and may cause churn. Uncomment if using 118 | # auto-import. 119 | # .idea/modules.xml 120 | # .idea/*.iml 121 | # .idea/modules 122 | 123 | # CMake 124 | cmake-build-*/ 125 | 126 | # Mongo Explorer plugin 127 | .idea/**/mongoSettings.xml 128 | 129 | # File-based project format 130 | *.iws 131 | 132 | # IntelliJ 133 | out/ 134 | 135 | # mpeltonen/sbt-idea plugin 136 | .idea_modules/ 137 | 138 | # JIRA plugin 139 | atlassian-ide-plugin.xml 140 | 141 | # Cursive Clojure plugin 142 | .idea/replstate.xml 143 | 144 | # Crashlytics plugin (for Android Studio and IntelliJ) 145 | com_crashlytics_export_strings.xml 146 | crashlytics.properties 147 | crashlytics-build.properties 148 | fabric.properties 149 | 150 | # Editor-based Rest Client 151 | .idea/httpRequests 152 | 153 | # Android studio 3.1+ serialized cache file 154 | .idea/caches/build_file_checksums.ser 155 | 156 | 157 | # Build files 158 | /lib 159 | /module 160 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/@textlint/website-generator/.prettierignore: -------------------------------------------------------------------------------- 1 | template/ 2 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/README.md: -------------------------------------------------------------------------------- 1 | # @textlint/website-generator 2 | 3 | Website generator using @textlint/script-compiler 4 | 5 | ## Install 6 | 7 | Install with [npm](https://www.npmjs.com/): 8 | 9 | npm install @textlint/website-generator 10 | 11 | ## Usage 12 | 13 | Usage 14 | $ textlint-website-generator 15 | 16 | Options 17 | --title [String] Website page title 18 | --placeholder [String] Placeholder text in generated website 19 | --cwd current working directory 20 | --textlintrc [path:String] path to .textlintrc file. Default: load .textlintrc.{json,yaml,js} 21 | --output-dir [path:String] output file path that is written of reported result. 22 | --metadataName [String] generated script name 23 | --metadataNamespace [String] generated script namespace 24 | 25 | Examples 26 | $ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" 27 | $ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" --title "rule tester" --placeholder "default text" 28 | 29 | ## Changelog 30 | 31 | See [Releases page](https://github.com/textlint/editor/releases). 32 | 33 | ## Running tests 34 | 35 | Install devDependencies and Run `npm test`: 36 | 37 | npm test 38 | 39 | ## Contributing 40 | 41 | Pull requests and stars are always welcome. 42 | 43 | For bugs and feature requests, [please create an issue](https://github.com/textlint/editor/issues). 44 | 45 | 1. Fork it! 46 | 2. Create your feature branch: `git checkout -b my-new-feature` 47 | 3. Commit your changes: `git commit -am 'Add some feature'` 48 | 4. Push to the branch: `git push origin my-new-feature` 49 | 5. Submit a pull request :D 50 | 51 | ## Author 52 | 53 | - [github/azu](https://github.com/azu) 54 | - [twitter/azu_re](https://twitter.com/azu_re) 55 | 56 | ## License 57 | 58 | MIT © azu 59 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/bin/cmd.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require("../lib/cli") 3 | .run() 4 | .then( 5 | ({ exitStatus, stderr, stdout }) => { 6 | if (stdout) { 7 | console.log(stdout); 8 | } 9 | if (stderr) { 10 | console.error(stderr); 11 | } 12 | process.exit(exitStatus); 13 | }, 14 | (error) => { 15 | console.error(error); 16 | process.exit(1); 17 | } 18 | ); 19 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@textlint/website-generator", 3 | "version": "0.17.0", 4 | "description": "Website generator using @textlint/script-compiler", 5 | "keywords": [ 6 | "textlint" 7 | ], 8 | "homepage": "https://github.com/textlint/editor/tree/master/packages/@textlint/website-generator/", 9 | "bugs": { 10 | "url": "https://github.com/textlint/editor/issues" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/textlint/editor.git" 15 | }, 16 | "license": "MIT", 17 | "author": "azu", 18 | "sideEffects": false, 19 | "main": "lib/index.js", 20 | "module": "module/index.js", 21 | "types": "lib/index.d.ts", 22 | "directories": { 23 | "lib": "lib", 24 | "test": "test" 25 | }, 26 | "bin": { 27 | "textlint-website-generator": "./bin/cmd.js" 28 | }, 29 | "files": [ 30 | "bin/", 31 | "lib/", 32 | "module", 33 | "template" 34 | ], 35 | "scripts": { 36 | "build": "tsc -p . && tsc --project ./tsconfig.module.json", 37 | "clean": "rimraf lib/ module/", 38 | "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", 39 | "prepublish": "npm run --if-present build", 40 | "generate-template": "node tools/website-generator.mjs", 41 | "watch": "tsc -p . --watch", 42 | "prepack": "npm run generate-template" 43 | }, 44 | "prettier": { 45 | "printWidth": 120, 46 | "singleQuote": false, 47 | "tabWidth": 4, 48 | "trailingComma": "none" 49 | }, 50 | "dependencies": { 51 | "@textlint/script-compiler": "^0.17.0", 52 | "meow": "^9.0.0", 53 | "read-pkg": "^5.2.0", 54 | "textchecker-element": "^0.17.0" 55 | }, 56 | "devDependencies": { 57 | "@types/mocha": "^10.0.1", 58 | "@types/node": "^18.13.0", 59 | "@types/rimraf": "3.0.0", 60 | "mocha": "^10.8.2", 61 | "prettier": "^2.3.0", 62 | "rimraf": "^3.0.2", 63 | "ts-node": "^10.9.1", 64 | "ts-node-test-register": "^10.0.0", 65 | "typescript": "^4.9.5" 66 | }, 67 | "publishConfig": { 68 | "access": "public" 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/src/cli.ts: -------------------------------------------------------------------------------- 1 | import meow from "meow"; 2 | import path from "path"; 3 | import { generateWebSite } from "./website-generator"; 4 | import readPkg from "read-pkg"; 5 | import { validateTextlintScriptMetadata } from "@textlint/script-compiler"; 6 | 7 | export const cli = meow( 8 | ` 9 | Usage 10 | $ textlint-website-generator 11 | 12 | Options 13 | --title [String] Website page title 14 | --placeholder [String] Placeholder text in generated website 15 | --cwd current working directory 16 | --textlintrc [path:String] path to .textlintrc file. Default: load .textlintrc.{json,yaml,js} 17 | --output-dir [path:String] output file path that is written of reported result. 18 | 19 | Metadata Options 20 | 21 | Metadata is inferred from package.json by default. 22 | If you want to set metadata by manually, please use theme flags. 23 | 24 | --metadataName [String] generated script name 25 | --metadataNamespace [String] generated script namespace 26 | --metadataHomepage [String] generated script homepage url 27 | --metadataVersion [String] generated script version 28 | 29 | Examples 30 | $ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" 31 | $ textlint-website-generator --output-dir ./dist --metadataName "script name" --metadataNamespace "https://example.com" --title "rule tester" --placeholder "default text" 32 | `, 33 | { 34 | flags: { 35 | title: { 36 | type: "string" 37 | }, 38 | placeholder: { 39 | type: "string" 40 | }, 41 | outputDir: { 42 | type: "string", 43 | isRequired: true 44 | }, 45 | textlintrc: { 46 | type: "string" 47 | }, 48 | mode: { 49 | type: "string", 50 | default: "production" 51 | }, 52 | metadataName: { 53 | type: "string" 54 | }, 55 | metadataNamespace: { 56 | type: "string" 57 | }, 58 | metadataHomepage: { 59 | type: "string" 60 | }, 61 | metadataVersion: { 62 | type: "string" 63 | }, 64 | // DEBUG option 65 | cwd: { 66 | type: "string", 67 | default: process.cwd() 68 | }, 69 | debug: { 70 | type: "boolean", 71 | default: false 72 | } 73 | }, 74 | autoHelp: true, 75 | autoVersion: true 76 | } 77 | ); 78 | 79 | export const run = async ( 80 | _input = cli.input, 81 | flags = cli.flags 82 | ): Promise<{ exitStatus: number; stdout: string | null; stderr: Error | null }> => { 83 | const pkg = await readPkg({ 84 | cwd: flags.cwd 85 | }); 86 | const metadata = { 87 | name: flags["metadataName"] ?? pkg.name, 88 | namespace: flags["metadataNamespace"] ?? pkg.homepage, 89 | homepage: flags["metadataHomepage"] ?? pkg.homepage, 90 | version: flags["metadataVersion"] ?? pkg.version 91 | }; 92 | // assert 93 | validateTextlintScriptMetadata(metadata); 94 | return generateWebSite({ 95 | title: flags.title ?? (pkg.name as string), 96 | placeholder: flags.placeholder ?? "", 97 | configFilePath: flags.textlintrc, 98 | cwd: flags.cwd, 99 | compileTarget: "webworker", 100 | outputDir: path.join(flags.cwd, flags.outputDir), 101 | mode: (flags.mode as "production" | "development") ?? "production", 102 | metadata 103 | }) 104 | .then(() => { 105 | return { 106 | exitStatus: 0, 107 | stdout: null, 108 | stderr: null 109 | }; 110 | }) 111 | .catch((error) => { 112 | return { 113 | exitStatus: 1, 114 | stderr: null, 115 | stdout: error 116 | }; 117 | }); 118 | }; 119 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/src/index.ts: -------------------------------------------------------------------------------- 1 | export { generateWebSite, generateWebSiteOptions } from "./website-generator"; 2 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/src/website-generator.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | import path from "path"; 3 | import { compile, compileOptions } from "@textlint/script-compiler"; 4 | 5 | export type generateWebSiteOptions = compileOptions & { 6 | title: string; 7 | placeholder: string; 8 | }; 9 | export const generateWebSite = async (options: generateWebSiteOptions) => { 10 | const templateDir = path.join(__dirname, "../template"); 11 | // textlint-worker.js 12 | await compile({ 13 | mode: "production", 14 | compileTarget: "webworker", 15 | outputDir: options.outputDir, 16 | configFilePath: options.configFilePath, 17 | cwd: options.cwd, 18 | metadata: options.metadata 19 | }); 20 | // copy template/textchecker-element.esm.js 21 | fs.copyFileSync( 22 | path.join(templateDir, "textchecker-element.esm.js"), 23 | path.join(options.outputDir, "textchecker-element.esm.js") 24 | ); 25 | 26 | // index.{js,html} 27 | const indexHtml = fs.readFileSync(path.join(templateDir, "index.html"), "utf-8"); 28 | const filledHTML = indexHtml.replace("{{title}}", options.title).replace("{{placeholder}}", options.placeholder); 29 | fs.writeFileSync(path.join(options.outputDir, "index.html"), filledHTML, "utf-8"); 30 | }; 31 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/template/README.md: -------------------------------------------------------------------------------- 1 | # Templates 2 | 3 | This directory contains templates for website-generator. 4 | 5 | These templates are generated by tools/website-generator.js. 6 | 7 | ## Edit 8 | 9 | - Edit `textchecker-element` package 10 | - Edit `tools/website-generator.js` 11 | - Run `npm run generate-template` 12 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "declaration": false, 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | "../src/**/*", 9 | "./**/*" 10 | ] 11 | } -------------------------------------------------------------------------------- /packages/@textlint/website-generator/tools/website-generator.mjs: -------------------------------------------------------------------------------- 1 | import * as fs from "node:fs"; 2 | import * as path from "node:path"; 3 | import { execFileSync } from "node:child_process"; 4 | import { fileURLToPath } from "url"; 5 | 6 | const __dirname = path.dirname(fileURLToPath(import.meta.url)); 7 | const textcheckerElementDir = path.join(__dirname, "../../../textchecker-element"); 8 | const outputDir = path.join(__dirname, "../template"); 9 | const createHTMLTemplate = () => { 10 | const html = fs.readFileSync(path.join(textcheckerElementDir, "./index.html"), "utf-8"); 11 | return html 12 | .replace(/[^]+<\/title>/, "<title>{{title}}") 13 | .replace(`"./index.ts"`, `"./textchecker-element.esm.js"`) 14 | .replace( 15 | /` 17 | ); 18 | }; 19 | try { 20 | // Write index.html 21 | fs.writeFileSync(path.join(outputDir, "index.html"), createHTMLTemplate(), "utf-8"); 22 | // Copy public-dist/textchecker-element.esm.js to template/ 23 | fs.copyFileSync( 24 | path.join(textcheckerElementDir, "./public-dist/textchecker-element.esm.js"), 25 | path.join(outputDir, "textchecker-element.esm.js") 26 | ); 27 | } catch (error) { 28 | console.error(error); 29 | process.exit(1); 30 | } 31 | -------------------------------------------------------------------------------- /packages/@textlint/website-generator/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "esModuleInterop": true, 7 | "newLine": "LF", 8 | "outDir": "./lib/", 9 | "target": "es5", 10 | "sourceMap": true, 11 | "declaration": true, 12 | "jsx": "preserve", 13 | "lib": [ 14 | "esnext", 15 | "dom" 16 | ], 17 | /* Strict Type-Checking Options */ 18 | "strict": true, 19 | /* Additional Checks */ 20 | /* Report errors on unused locals. */ 21 | "noUnusedLocals": true, 22 | /* Report errors on unused parameters. */ 23 | "noUnusedParameters": true, 24 | /* Report error when not all code paths in function return a value. */ 25 | "noImplicitReturns": true, 26 | /* Report errors for fallthrough cases in switch statement. */ 27 | "noFallthroughCasesInSwitch": true 28 | }, 29 | "include": [ 30 | "src/**/*" 31 | ], 32 | "exclude": [ 33 | ".git", 34 | "node_modules" 35 | ] 36 | } -------------------------------------------------------------------------------- /packages/@textlint/website-generator/tsconfig.module.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "module": "ESNext", 5 | "outDir": "./module/", 6 | } 7 | } -------------------------------------------------------------------------------- /packages/textchecker-element/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/env" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /packages/textchecker-element/.gitignore: -------------------------------------------------------------------------------- 1 | # build file 2 | public-dist/ 3 | public/textlint-worker.js 4 | temp/ 5 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Node.gitignore 6 | dist 7 | .cache 8 | module 9 | lib 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | *.pid.lock 22 | 23 | # Directory for instrumented libs generated by jscoverage/JSCover 24 | lib-cov 25 | 26 | # Coverage directory used by tools like istanbul 27 | coverage 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # TypeScript v1 declaration files 49 | typings/ 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Optional REPL history 58 | .node_repl_history 59 | 60 | # Output of 'npm pack' 61 | *.tgz 62 | 63 | # Yarn Integrity file 64 | .yarn-integrity 65 | 66 | # dotenv environment variables file 67 | .env 68 | .env.test 69 | 70 | # parcel-bundler cache (https://parceljs.org/) 71 | .cache 72 | 73 | # next.js build output 74 | .next 75 | 76 | # nuxt.js build output 77 | .nuxt 78 | 79 | # vuepress build output 80 | .vuepress/dist 81 | 82 | # Serverless directories 83 | .serverless/ 84 | 85 | # FuseBox cache 86 | .fusebox/ 87 | 88 | # DynamoDB Local files 89 | .dynamodb/ 90 | 91 | 92 | ### https://raw.github.com/github/gitignore/d2c1bb2b9c72ead618c9f6a48280ebc7a8e0dff6/Global/JetBrains.gitignore 93 | 94 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 95 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 96 | 97 | # User-specific stuff 98 | .idea/**/workspace.xml 99 | .idea/**/tasks.xml 100 | .idea/**/usage.statistics.xml 101 | .idea/**/dictionaries 102 | .idea/**/shelf 103 | 104 | # Generated files 105 | .idea/**/contentModel.xml 106 | 107 | # Sensitive or high-churn files 108 | .idea/**/dataSources/ 109 | .idea/**/dataSources.ids 110 | .idea/**/dataSources.local.xml 111 | .idea/**/sqlDataSources.xml 112 | .idea/**/dynamic.xml 113 | .idea/**/uiDesigner.xml 114 | .idea/**/dbnavigator.xml 115 | 116 | # Gradle 117 | .idea/**/gradle.xml 118 | .idea/**/libraries 119 | 120 | # Gradle and Maven with auto-import 121 | # When using Gradle or Maven with auto-import, you should exclude module files, 122 | # since they will be recreated, and may cause churn. Uncomment if using 123 | # auto-import. 124 | # .idea/modules.xml 125 | # .idea/*.iml 126 | # .idea/modules 127 | 128 | # CMake 129 | cmake-build-*/ 130 | 131 | # Mongo Explorer plugin 132 | .idea/**/mongoSettings.xml 133 | 134 | # File-based project format 135 | *.iws 136 | 137 | # IntelliJ 138 | out/ 139 | 140 | # mpeltonen/sbt-idea plugin 141 | .idea_modules/ 142 | 143 | # JIRA plugin 144 | atlassian-ide-plugin.xml 145 | 146 | # Cursive Clojure plugin 147 | .idea/replstate.xml 148 | 149 | # Crashlytics plugin (for Android Studio and IntelliJ) 150 | com_crashlytics_export_strings.xml 151 | crashlytics.properties 152 | crashlytics-build.properties 153 | fabric.properties 154 | 155 | # Editor-based Rest Client 156 | .idea/httpRequests 157 | 158 | # Android studio 3.1+ serialized cache file 159 | .idea/caches/build_file_checksums.ser 160 | 161 | 162 | # Build files 163 | /lib 164 | /module 165 | -------------------------------------------------------------------------------- /packages/textchecker-element/.mocharc.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": [ 3 | "ts-node-test-register" 4 | ] 5 | } -------------------------------------------------------------------------------- /packages/textchecker-element/.prettierignore: -------------------------------------------------------------------------------- 1 | public-dist 2 | -------------------------------------------------------------------------------- /packages/textchecker-element/.textlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "preset-ja-technical-writing": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/textchecker-element/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 azu 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /packages/textchecker-element/README.md: -------------------------------------------------------------------------------- 1 | # textchecker-element 2 | 3 | Overlay text checker Web Component. 4 | 5 | - Attach `