Skip to content

Commit

Permalink
Chore: pin the version of prettier used to lint this module (refs #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
not-an-aardvark committed Jan 28, 2017
1 parent 090e1c5 commit db85633
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';

const fs = require('fs');
const path = require('path');
const PACKAGE_NAME = require('./package').name;
Expand All @@ -10,16 +11,16 @@ if (!fs.existsSync(SYMLINK_LOCATION)) {
}

module.exports = {
plugins: [ 'node', 'eslint-plugin', PACKAGE_NAME ],
plugins: ['node', 'eslint-plugin', PACKAGE_NAME],
extends: [
'not-an-aardvark/node',
'plugin:node/recommended',
'plugin:eslint-plugin/recommended'
],
root: true,
rules: {
'prettier/prettier': [ 'error', { singleQuote: true } ],
'eslint-plugin/report-message-format': [ 'error', '^[^a-z].*\\.$' ],
'prettier/prettier': ['error', { singleQuote: true }],
'eslint-plugin/report-message-format': ['error', '^[^a-z].*\\.$'],
'array-bracket-spacing': 'off',
'comma-dangle': 'off',
'lines-around-directive': 'off',
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Teddy Katz
*/
'use strict';

// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
Expand Down
9 changes: 5 additions & 4 deletions lib/rules/prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Teddy Katz
*/
'use strict';

const util = require('util');
const prettier = require('prettier');
const astUtils = require('eslint/lib/ast-utils');
Expand All @@ -11,7 +12,7 @@ const astUtils = require('eslint/lib/ast-utils');
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: { fixable: 'code', schema: [ { type: 'object' } ] },
meta: { fixable: 'code', schema: [{ type: 'object' }] },
create(context) {
const sourceCode = context.getSourceCode();

Expand All @@ -35,8 +36,8 @@ module.exports = {
const foundChar = firstBadIndex >= sourceCode.text.length
? 'EOF'
: firstBadIndex === -1
? sourceCode.text[desiredText.length]
: sourceCode.text[firstBadIndex];
? sourceCode.text[desiredText.length]
: sourceCode.text[firstBadIndex];

context.report({
loc: astUtils.getLocationFromRangeIndex(
Expand All @@ -49,7 +50,7 @@ module.exports = {
foundChar: util.inspect(foundChar)
},
fix: fixer =>
fixer.replaceTextRange([ 0, sourceCode.text.length ], desiredText)
fixer.replaceTextRange([0, sourceCode.text.length], desiredText)
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"eslint-plugin-eslint-plugin": "^0.2.1",
"eslint-plugin-node": "^3.0.5",
"mocha": "^3.1.2",
"prettier": ">= 0.11.0"
"prettier": "^0.13.1"
},
"engines": {
"node": ">=4.0.0"
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/rules/prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Teddy Katz
*/
'use strict';

// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
Expand All @@ -19,7 +20,7 @@ ruleTester.run('prettier', rule, {
valid: [
'foo(bar);\n',
'foo("bar");\n',
{ code: "foo('bar');\n", options: [ { singleQuote: true } ] }
{ code: "foo('bar');\n", options: [{ singleQuote: true }] }
],
invalid: [
{
Expand Down

0 comments on commit db85633

Please sign in to comment.