Skip to content

Add textlint#1

Open
azu wants to merge 83 commits into
masterfrom
textlint
Open

Add textlint#1
azu wants to merge 83 commits into
masterfrom
textlint

Conversation

@azu
Copy link
Copy Markdown
Member

@azu azu commented Mar 27, 2016

Add Markdown and plain texts support.

Would We created a fork of astexplorer?
It is specific usage of textlint and textlint is a minor tool.

Pros

Would the user of astexplorer need textlint support?

Cons

  • Maintaince cost 🆙
  • Drop saving feature

Ref: textlint/textlint#176

@azu
Copy link
Copy Markdown
Member Author

azu commented Mar 27, 2016

ERROR in /Users/azu/~/remark/index.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/remark
 @ /Users/azu/~/remark/index.js 21:13-41

ERROR in /Users/azu/~/remark/lib/parse.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/remark/lib
 @ /Users/azu/~/remark/lib/parse.js 26:20-52

ERROR in /Users/azu/~/character-entities/index.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/character-entities
 @ /Users/azu/~/character-entities/index.js 17:17-40

ERROR in /Users/azu/~/character-entities-legacy/index.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/character-entities-legacy
 @ /Users/azu/~/character-entities-legacy/index.js 17:17-40

ERROR in /Users/azu/~/character-entities-html4/index.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/character-entities-html4
 @ /Users/azu/~/character-entities-html4/index.js 17:17-40

ERROR in /Users/azu/~/character-reference-invalid/index.js
Module not found: Error: Cannot resolve module 'json' in /Users/azu/node_modules/character-reference-invalid
 @ /Users/azu/~/character-reference-invalid/index.js 17:17-40

requiring json throw error...

npm install webpack@beta resolve this issue.

@azu
Copy link
Copy Markdown
Member Author

azu commented Mar 27, 2016

ast explorer 2016-03-27 12-42-38

@azu
Copy link
Copy Markdown
Member Author

azu commented Mar 27, 2016

Currenlty, Transform of textlint don't work.

da1e9eb

import compileModule from '../../../utils/compileModule';
import pkg from 'textlint/package.json';

const ID = 'textlint';

export default {
    id: ID,
    displayName: ID,
    version: pkg.version,
    homepage: pkg.homepage,

    defaultParserID: 'textlint:markdown-to-ast',

    loadTransformer(callback) {
        require(['textlint/lib/textlint-core', 'babel-core'], (TextLintCore, babel) => {
            callback({ TextLintCore, babel });
        })
    },

    transform({TextLintCore, babel}, transformCode, code) {
        console.log(TextLintCore);
        const textlintCore = new TextLintCore();
        let rule = compileModule( // eslint-disable-line no-shadow
            babel.transform(transformCode).code
        );
        textlintCore.setupRules({
            'astExplorerRule': rule
        });
        return textlintCore.lintText(code, ".md").then(result => {
            return JSON.stringify(result);
        });
    }
};

Error

index.js?e7c5:62 Uncaught (in promise) TypeError: Cannot redefine property: exports
    at Function.defineProperty (native)
    at Object.eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:39:2), <anonymous>:62:8)
    at eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:39:2), <anonymous>:67:30)
    at Object.webpackJsonp../node_modules/ansi-styles/index.js (http://127.0.0.1:8080/0.js:39:2)
    at __webpack_require__ (http://127.0.0.1:8080/vendor.js:48:30)
    at Object.eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:2189:2), <anonymous>:3:18)
    at eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:2189:2), <anonymous>:118:30)
    at Object.webpackJsonp../node_modules/chalk/index.js (http://127.0.0.1:8080/0.js:2189:2)
    at __webpack_require__ (http://127.0.0.1:8080/vendor.js:48:30)
    at eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:309:2), <anonymous>:24:14)
    at Object.webpackJsonp../node_modules/babel-core/lib/helpers/code-frame.js (http://127.0.0.1:8080/0.js:309:2)
    at __webpack_require__ (http://127.0.0.1:8080/vendor.js:48:30)
    at eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:1579:2), <anonymous>:17:25)
    at Object.webpackJsonp../node_modules/babel-core/lib/traversal/path/replacement.js (http://127.0.0.1:8080/0.js:1579:2)
    at __webpack_require__ (http://127.0.0.1:8080/vendor.js:48:30)
    at eval (eval at <anonymous> (http://127.0.0.1:8080/0.js:1479:2), <anonymous>:172:53)(anonymous function) @ index.js?e7c5:62(anonymous function) @ index.js?e7c5:67webpackJsonp../node_modules/ansi-styles/index.js @ 0.js:39__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?d69f:3(anonymous function) @ index.js?d69f:118webpackJsonp../node_modules/chalk/index.js @ 0.js:2189__webpack_require__ @ vendor.js:48(anonymous function) @ code-frame.js?6fae:24webpackJsonp../node_modules/babel-core/lib/helpers/code-frame.js @ 0.js:309__webpack_require__ @ vendor.js:48(anonymous function) @ replacement.js?6cf9:17webpackJsonp../node_modules/babel-core/lib/traversal/path/replacement.js @ 0.js:1579__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?8e66:172webpackJsonp../node_modules/babel-core/lib/traversal/path/index.js @ 0.js:1479__webpack_require__ @ vendor.js:48(anonymous function) @ context.js?dbf0:16webpackJsonp../node_modules/babel-core/lib/traversal/context.js @ 0.js:1389__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?e6c1:13webpackJsonp../node_modules/babel-core/lib/traversal/index.js @ 0.js:1409__webpack_require__ @ vendor.js:48(anonymous function) @ plugin-pass.js?398e:19webpackJsonp../node_modules/babel-core/lib/transformation/plugin-pass.js @ 0.js:739__webpack_require__ @ vendor.js:48(anonymous function) @ plugin.js?74c9:16webpackJsonp../node_modules/babel-core/lib/transformation/plugin.js @ 0.js:749__webpack_require__ @ vendor.js:48(anonymous function) @ transformer.js?b6c7:12webpackJsonp../node_modules/babel-core/lib/transformation/transformer.js @ 0.js:759__webpack_require__ @ vendor.js:48(anonymous function) @ plugin-manager.js?5e76:20webpackJsonp../node_modules/babel-core/lib/transformation/file/plugin-manager.js @ 0.js:449__webpack_require__ @ vendor.js:48(anonymous function) @ pipeline.js?eb65:12webpackJsonp../node_modules/babel-core/lib/transformation/pipeline.js @ 0.js:729__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?0346:12webpackJsonp../node_modules/babel-core/lib/transformation/index.js @ 0.js:589__webpack_require__ @ vendor.js:48(anonymous function) @ node.js?b46f:25webpackJsonp../node_modules/babel-core/lib/api/node.js @ 0.js:79__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?99f1:1webpackJsonp../node_modules/babel-core/index.js @ 0.js:69__webpack_require__ @ vendor.js:48(anonymous function) @ index.js?0f54:15Promise.resolve (async)webpackJsonpCallback @ vendor.js:19(anonymous function) @ 3.js:1

@azu
Copy link
Copy Markdown
Member Author

azu commented Mar 27, 2016

Work transformers!
ast explorer 2016-03-27 13-36-32

@azu
Copy link
Copy Markdown
Member Author

azu commented Mar 27, 2016

acb5dfb

Add promise support tot transform method.

textlint#lintText return promise.

@azu azu changed the title [WIP] Add textlint Add textlint Jun 10, 2016
azu pushed a commit that referenced this pull request May 24, 2021
Update with changes from fkling/astexplorer
azu pushed a commit that referenced this pull request Jul 24, 2025
* Add protobuf parser

* feat: add protocol buffers parser

* doc: add pbkit to README

* remove an unused babel plugin

* remove verdored parser

* chore: up pbkit (#1)

it resolves some parse error cases

Co-authored-by: JongChan Choi <disjukr@naver.com>
azu and others added 14 commits July 25, 2025 07:10
- webpack.config.jsにnode:assertのaliasとnode設定を追加
- PR用のCIワークフロー(test.yml)を追加してビルドテストを実行

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
fix(build): webpackのnode:assertモジュール解決エラーを修正
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
chore(deps): update textlint to v15.3.0
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
chore(deps): update textlint to v15.5.1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

View 6 additional findings in Devin Review.

Open in Devin Review

}

getPath() {
return `/snippet/${this.hash}}`;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Extra closing brace } in getPath() corrupts the URL hash

The getPath() method returns /snippet/${this.hash}} with a stray } after the template literal interpolation. This extra brace is appended to the URL hash via storage/index.js:20 (global.location.hash = revision.getPath()). When a user later navigates back to this URL, getIDAndRevisionFromHash() at urlStore.js:7 will capture the hash including the trailing }, and codec.decompress() will attempt to decode a corrupted string, likely throwing an error or producing garbage output.

Suggested change
return `/snippet/${this.hash}}`;
return `/snippet/${this.hash}`;
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

},

transform({ TextlintKernel, plugin }, transformCode, code) {
const kernel = new Kernel();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 new Kernel() references undefined variable instead of TextlintKernel

In the transform method, the code uses new Kernel() but the parameter is destructured as { TextlintKernel, plugin }. Kernel is never defined, so this will throw a ReferenceError at runtime whenever the textlint-txt transformer is executed. The other transformers (markdown at textlint-md/transformers/textlint-markdown-to-ast/index.js:40 and HTML at textlint-html/transformers/textlint-plugin-html/index.js:41) correctly use new TextlintKernel().

Suggested change
const kernel = new Kernel();
const kernel = new TextlintKernel();
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +34 to +36
require(['@textlint/kernel'], ({ TextlintKernel }, { default: plugin }) => {
callback({ TextlintKernel, plugin });
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 loadTransformer for textlint-txt only requires one module but destructures two callback arguments

The require call passes only ['@textlint/kernel'] (one module), but the callback destructures two arguments: ({ TextlintKernel }, { default: plugin }). The second argument will be undefined, and destructuring undefined throws TypeError: Cannot destructure property 'default' of 'undefined'. Compare with the markdown transformer at textlint-md/transformers/textlint-markdown-to-ast/index.js:34 which correctly requires both modules: ['@textlint/kernel', '@textlint/textlint-plugin-markdown']. The txt transformer should similarly require @textlint/textlint-plugin-text.

Suggested change
require(['@textlint/kernel'], ({ TextlintKernel }, { default: plugin }) => {
callback({ TextlintKernel, plugin });
})
require(['@textlint/kernel', '@textlint/textlint-plugin-text'], ({ TextlintKernel }, { default: plugin }) => {
callback({ TextlintKernel, plugin });
})
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

export default {
...defaultParserInterface,
id: ID,
displayName: "@textlint/text-to-ast",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Markdown parser displayName incorrectly shows @textlint/text-to-ast instead of @textlint/markdown-to-ast

The markdown parser at textlint-md/textlint-markdown-to-ast.js has displayName: "@textlint/text-to-ast" but the id is textlint:markdown-to-ast and it loads @textlint/markdown-to-ast. This appears to be a copy-paste error from the text parser. Users will see the wrong parser name in the UI.

Suggested change
displayName: "@textlint/text-to-ast",
displayName: "@textlint/markdown-to-ast",
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View 8 additional findings in Devin Review.

Open in Devin Review

Comment on lines +103 to +105
getParserSettings() {
return this.data.settings[this.data.parserID];
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 getParserSettings() crashes when this.data.settings is undefined

In website/src/storage/urlStore.js:103-104, getParserSettings() directly accesses this.data.settings[this.data.parserID] without checking if settings exists. If a decompressed snippet has no settings field, this throws a TypeError. The existing parse.js implementation (website/src/storage/parse.js:139-143) handles this correctly with a null check before accessing the property. The caller at website/src/store/reducers.js:214 uses revision.getParserSettings() || ..., which would handle null/undefined returns, but cannot catch the thrown exception.

Suggested change
getParserSettings() {
return this.data.settings[this.data.parserID];
}
getParserSettings() {
const settings = this.data.settings;
if (!settings) {
return null;
}
return settings[this.data.parserID];
}
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

renovate Bot added 2 commits May 11, 2026 15:01
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant