Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Dec 29, 2014
0 parents commit 04327fc
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Node.gitignore

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules


### https://raw.github.com/github/gitignore/408c616ae0ad8f4b8101d8e876b9b67ac6b14059/Global/JetBrains.gitignore

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

*.iml

## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2014 azu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# spellcheck-tech-word textlint rule

This module for [azu/textlint](https://github.com/azu/textlint "azu/textlint").



- [ ] Write a project description

## Installation

- [ ] Describe the installation process

## Usage

- [ ] Write usage instructions

## Contributing

1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D

## License

MIT
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "spellcheck-tech-word-textlint-rule",
"description": "textlint rule: spell check technical word for japanese.",
"version": "1.0.0",
"homepage": "https://github.com/azu/spellcheck-tech-word-textlint-rule/",
"repository": {
"type": "git",
"url": "https://github.com/azu/spellcheck-tech-word-textlint-rule.git"
},
"main": "spellcheck-tech-word.js",
"scripts": {
"test": "mocha test/*.js"
},
"directories": {
"test": "test/"
},
"author": "azu",
"license": "MIT",
"bugs": {
"url": "https://github.com/azu/spellcheck-tech-word-textlint-rule/issues"
},
"devDependencies": {
"espower-loader": "^0.10.0",
"intelli-espower-loader": "^0.5.0",
"mocha": "^2.1.0",
"power-assert": "^0.10.0",
"textlint": "^1.0.1"
},
"dependencies": {
"technical-word-rules": "git://github.com/azu/technical-word-rules"
}
}
36 changes: 36 additions & 0 deletions spellcheck-tech-word.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// LICENSE : MIT
"use strict";
var dictionaryItems = require("technical-word-rules");
/**
* @param {RuleContext} context
*/
module.exports = function (context) {
var exports = {};
exports[context.Syntax.Str] = function (node) {
var text = context.getSource(node);
for (var i = 0; i < dictionaryItems.length; i++) {
var dictionary = dictionaryItems[i];
var query = new RegExp(dictionary.pattern, dictionary.flag);
var match = query.exec(text);
if (!match) {
continue;
}
var matchedString = match[0];
// s/Web/Web/iは大文字小文字無視してWebに変換したいという意味に対応する
if (dictionary.flag != null) {
var strictQuery = new RegExp(dictionary.pattern);
var isStrictMatch = strictQuery.test(match[0]);
// /Web/i でマッチするけど、 /Web/ でマッチするならそれは除外する
if (isStrictMatch) {
continue;
}
}
// [start, end]
var matchedStartIndex = match.index + 1;
var expected = matchedString.replace(query, dictionary.expected);
// line, column
context.report(node, (new context.RuleError(matchedString + " => " + expected, matchedStartIndex)));
}
};
return exports;
};
1 change: 1 addition & 0 deletions test/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require intelli-espower-loader
25 changes: 25 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// LICENSE : MIT
"use strict";
var assert = require("power-assert");
var fs = require("fs"),
path = require("path");
var textlint = require("textlint").textlint;
describe("spellcheck-tech-word.js", function () {
beforeEach(function () {
textlint.setupRules({
// rule-key : rule
"spellcheck-tech-word": require("../spellcheck-tech-word")
});
});
afterEach(function () {
textlint.resetRules();
});
it("should lint wrong tech words", function () {
var filePath = path.join(__dirname, "test.md");
var result = textlint.lintFile(filePath);
assert(result.filePath === filePath);
assert(result.messages.length > 0);
var message = result.messages[0].message;
assert.equal(message, "HTML Import => HTML Imports");
});
});
4 changes: 4 additions & 0 deletions test/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# TEST file

HTML Import is bad word.
HTML Imports is correct.

0 comments on commit 04327fc

Please sign in to comment.