{"action":"created","issue":{"url":"https://api.github.com/repos/textlint/textlint/issues/211","repository_url":"https://api.github.com/repos/textlint/textlint","labels_url":"https://api.github.com/repos/textlint/textlint/issues/211/labels{/name}","comments_url":"https://api.github.com/repos/textlint/textlint/issues/211/comments","events_url":"https://api.github.com/repos/textlint/textlint/issues/211/events","html_url":"https://github.com/textlint/textlint/issues/211","id":156137506,"number":211,"title":"`--fix` with ignoring rule","user":{"login":"azu","id":19714,"avatar_url":"https://avatars.githubusercontent.com/u/19714?v=3","gravatar_id":"","url":"https://api.github.com/users/azu","html_url":"https://github.com/azu","followers_url":"https://api.github.com/users/azu/followers","following_url":"https://api.github.com/users/azu/following{/other_user}","gists_url":"https://api.github.com/users/azu/gists{/gist_id}","starred_url":"https://api.github.com/users/azu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azu/subscriptions","organizations_url":"https://api.github.com/users/azu/orgs","repos_url":"https://api.github.com/users/azu/repos","events_url":"https://api.github.com/users/azu/events{/privacy}","received_events_url":"https://api.github.com/users/azu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/textlint/textlint/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-22T06:22:45Z","updated_at":"2016-05-23T14:11:55Z","closed_at":null,"body":"We have supported ignoring rule as experimental #193 \r\n\r\nCurrently, ignoring don't work with fixer.\r\n\r\nThis issue describe this bug. It is a bug of textlint-self.\r\nhttps://github.com/textlint/textlint-rule-ignore-comments/issues/1\r\n\r\n## Problem\r\n\r\nCurrent, implementation of fixer.\r\n\r\n> Parse text -> A fix rule -> re-parse text -> B fix rule ....\r\n\r\nThis design prefer much fixed than performance.\r\n\r\n- https://github.com/textlint/textlint/blob/60633fe4530ee21e1da2d37386a568c5331f372c/src/fixer/fixer-processor.js#L36\r\n\r\n**fixer and ignoring** \r\n\r\nExpected:\r\n\r\n```\r\nParse text -> A fix rule -> re-parse text -> B fix rule ....\r\n                  ^ + C ignoring rule                  ^ + C ignoring rule\r\n```\r\n\r\nActual : \r\n\r\n> Parse text -> A fix rule -> re-parse text -> B fix rule -> re-parse text -> C ignoring rule ...\r\n\r\nNot work ignoring.\r\n\r\nIt should be fixed"},"comment":{"url":"https://api.github.com/repos/textlint/textlint/issues/comments/220991535","html_url":"https://github.com/textlint/textlint/issues/211#issuecomment-220991535","issue_url":"https://api.github.com/repos/textlint/textlint/issues/211","id":220991535,"user":{"login":"azu","id":19714,"avatar_url":"https://avatars.githubusercontent.com/u/19714?v=3","gravatar_id":"","url":"https://api.github.com/users/azu","html_url":"https://github.com/azu","followers_url":"https://api.github.com/users/azu/followers","following_url":"https://api.github.com/users/azu/following{/other_user}","gists_url":"https://api.github.com/users/azu/gists{/gist_id}","starred_url":"https://api.github.com/users/azu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azu/subscriptions","organizations_url":"https://api.github.com/users/azu/orgs","repos_url":"https://api.github.com/users/azu/repos","events_url":"https://api.github.com/users/azu/events{/privacy}","received_events_url":"https://api.github.com/users/azu/received_events","type":"User","site_admin":false},"created_at":"2016-05-23T14:11:55Z","updated_at":"2016-05-23T14:11:55Z","body":"I've implemented proof of concept of filter plugin.\r\n\r\n- https://github.com/azu/textlint-filter-plugin-comments\r\n- Notice: textlint not support this filter plguins. contain many hacks.\r\n\r\n```js\r\nconst traverse = require(\"txt-ast-traverse\").traverse;\r\n// FIXME: a plugin/rule should not depended on textlint module\r\n// It cause problem between textlint ver a and textlint ver b\r\n// e.g.) 5.0 and 6.0 are duplicated installed... sad\r\nconst TextLintNodeType = require(\"textlint\").TextLintNodeType;\r\nconst EventEmitter = require(\"events\");\r\nimport ruleCreator from \"./filter/textlint-rule-ignore-comments\";\r\nimport StatusManager from \"./filter/StatusManager\";\r\n// this copied from textlint core\r\nimport ignoringFilter from \"./ignoring-filter\"\r\nexport default class FilterPlugin {\r\n    /**\r\n     * @param config config is textlint config\r\n     */\r\n    constructor(config) {\r\n        this.config = config;\r\n    }\r\n\r\n    /**\r\n     * This plugin filter `messages` using `AST`.\r\n     *\r\n     * @param messages\r\n     * @param AST\r\n     * @returns {Array} filtered messages\r\n     */\r\n    filter(messages, AST) {\r\n        // TODO: this has two issue.\r\n        // 1. depended on textlint module\r\n        // 2. use `raw` property(not recommended)\r\n        const content = AST.raw;\r\n        const statusManager = new StatusManager(content.length);\r\n        const rule = ruleCreator({Syntax: TextLintNodeType, content, statusManager});\r\n        const eventEmitter = new EventEmitter();\r\n        // listen type and handler\r\n        // This implementation is same textlint core\r\n        Object.keys(rule).forEach(nodeType => {\r\n            eventEmitter.on(nodeType, rule[nodeType]);\r\n        });\r\n        // traverse AST and found ignoring point\r\n       // Note: implement own traverser\r\n        traverse(AST, {\r\n            enter(node) {\r\n                eventEmitter.emit(node.type, node);\r\n            },\r\n            leave(node) {\r\n                eventEmitter.emit(node.type + \":exit\", node);\r\n            }\r\n        });\r\n        // get result filtering point\r\n        const ignoringMessages = statusManager.getIgnoringMessages();\r\n        // filter messages by ignoringMessages\r\n        return ignoringFilter(messages, ignoringMessages);\r\n    }\r\n}\r\n```\r\n\r\nThis separation is fair, but it is very difficult to implement.\r\ntextlint core should provide helper to implement filter plugin..."}}
{"actor":{"display_login":"azu"}}