Skip to content

Commit

Permalink
Initial config files + a hello-world-y test rule to get my feet wet.
Browse files Browse the repository at this point in the history
  • Loading branch information
benmosher committed Mar 15, 2015
1 parent 8d88433 commit 75c2d47
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
indent_style = space
end_of_line = lf
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
env:
node: true
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.rules = {
"test-import-visitor": require("./lib/rules/test-import-visitor")
};
7 changes: 7 additions & 0 deletions lib/rules/test-import-visitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = function (context) {
return {
"ImportDeclaration": function (node) {
context.report(node, "This is an import!");
}
};
};
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "eslint-plugin-import",
"version": "0.0.1",
"description": "Import with sanity.",
"main": "index.js",
"directories": {
"test": "tests"
},
"scripts": {
"test": "mocha --recursive tests/"
},
"repository": {
"type": "git",
"url": "https://github.com/benmosher/eslint-plugin-import"
},
"keywords": [
"eslint",
"eslintplugin",
"es6",
"jsnext"
],
"author": "Ben Mosher (me@benmosher.com)",
"license": "MIT",
"bugs": {
"url": "https://github.com/benmosher/eslint-plugin-import/issues"
},
"homepage": "https://github.com/benmosher/eslint-plugin-import",
"devDependencies": {
"eslint": "^0.17.0",
"eslint-tester": "^0.6.0",
"mocha": "^2.2.1"
}
}
19 changes: 19 additions & 0 deletions tests/lib/rules/test-import-visitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use strict";

var linter = require("eslint").linter,
ESLintTester = require("eslint-tester"),
eslintTester = new ESLintTester(linter);

eslintTester.addRuleTest("lib/rules/test-import-visitor", {
valid: [
"var validVariable = true;",
],

invalid: [
{
code: "import foo from 'bar'",
ecmaFeatures: { modules: true },
errors: [ { message: "This is an import!" } ]
}
]
});

0 comments on commit 75c2d47

Please sign in to comment.