Socket
Socket
Sign inDemoInstall

eslint-plugin-prettier

Package Overview
Dependencies
154
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

14

.eslintrc.js
'use strict';
const fs = require('fs');

@@ -13,17 +14,14 @@ const path = require('path');

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'
'plugin:eslint-plugin/recommended',
'prettier'
],
root: true,
rules: {
'prettier/prettier': [ 'error', { singleQuote: true } ],
'eslint-plugin/report-message-format': [ 'error', '^[^a-z].*\\.$' ],
'array-bracket-spacing': 'off',
'comma-dangle': 'off',
'lines-around-directive': 'off',
'space-before-function-paren': 'off'
'prettier/prettier': ['error', { singleQuote: true }],
'eslint-plugin/report-message-format': ['error', '^[^a-z].*\\.$']
}
};
# Changelog
## v2.0.1 (2017-02-26)
* Docs: add travis badge to README.md ([1daa495](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/1daa49558a7f904f8d307d3d434a9bc80f41fee6))
* Upgrade: prettier to 0.18.0 ([1700e41](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/1700e41b2c66721b521e766052cfaa3cc59cd219))
* Chore: use eslint-config-prettier ([c979b84](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/c979b84641c42f8870c21c69d22b75916c8511e0))
* Fix: avoid relying on an internal eslint function ([5296930](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/5296930386ef28a26e0f5c606d107e4293f51620))
* Docs: mention eslint-config-prettier in README.md ([3fd855d](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/3fd855dfb356c8616c19b51b70eb5fcb8fb90c9c))
* Chore: pin the version of prettier used to lint this module (refs [#1](https://github.com/not-an-aardvark/eslint-plugin-prettier/issues/1)) ([db85633](https://github.com/not-an-aardvark/eslint-plugin-prettier/commit/db85633a0360caeebbf5b20195a3bc19ebf7177a))
## v2.0.0 (2017-01-28)

@@ -4,0 +13,0 @@

@@ -5,3 +5,5 @@ /**

*/
'use strict';
// ------------------------------------------------------------------------------

@@ -8,0 +10,0 @@ // Requirements

@@ -5,6 +5,7 @@ /**

*/
'use strict';
const util = require('util');
const prettier = require('prettier');
const astUtils = require('eslint/lib/ast-utils');

@@ -15,6 +16,23 @@ // ------------------------------------------------------------------------------

module.exports = {
meta: { fixable: 'code', schema: [ { type: 'object' } ] },
meta: { fixable: 'code', schema: [{ type: 'object' }] },
create(context) {
const sourceCode = context.getSourceCode();
/**
* Gets the location of a given index in the source code
* @param {number} index An index in the source code
* @returns {object} An object containing numberic `line` and `column` keys
*/
function getLocation(index) {
// If sourceCode.getLocFromIndex is available from eslint, use it.
// Otherwise, use the private version from eslint/lib/ast-utils.
return sourceCode.getLocFromIndex
? sourceCode.getLocFromIndex(index)
: require('eslint/lib/ast-utils').getLocationFromRangeIndex(
sourceCode,
index
);
}
return {

@@ -31,4 +49,3 @@ Program() {

// Find the first character that differs
const firstBadIndex = Array
.from(desiredText)
const firstBadIndex = Array.from(desiredText)
.findIndex((char, index) => char !== sourceCode.text[index]);

@@ -41,8 +58,7 @@ const expectedChar = firstBadIndex === -1

: firstBadIndex === -1
? sourceCode.text[desiredText.length]
: sourceCode.text[firstBadIndex];
? sourceCode.text[desiredText.length]
: sourceCode.text[firstBadIndex];
context.report({
loc: astUtils.getLocationFromRangeIndex(
sourceCode,
loc: getLocation(
firstBadIndex === -1 ? desiredText.length : firstBadIndex

@@ -56,3 +72,3 @@ ),

fix: fixer =>
fixer.replaceTextRange([ 0, sourceCode.text.length ], desiredText)
fixer.replaceTextRange([0, sourceCode.text.length], desiredText)
});

@@ -59,0 +75,0 @@ }

{
"name": "eslint-plugin-prettier",
"version": "2.0.0",
"version": "2.0.1",
"description": "Runs prettier as an eslint rule",

@@ -34,6 +34,7 @@ "keywords": [

"eslint-config-not-an-aardvark": "^2.0.0",
"eslint-config-prettier": "^1.3.0",
"eslint-plugin-eslint-plugin": "^0.2.1",
"eslint-plugin-node": "^3.0.5",
"mocha": "^3.1.2",
"prettier": ">= 0.11.0"
"prettier": "^0.18.0"
},

@@ -40,0 +41,0 @@ "engines": {

@@ -1,2 +0,2 @@

# eslint-plugin-prettier
# eslint-plugin-prettier [![Build Status](https://travis-ci.org/not-an-aardvark/eslint-plugin-prettier.svg?branch=master)](https://travis-ci.org/not-an-aardvark/eslint-plugin-prettier)

@@ -64,3 +64,3 @@ Runs [prettier](https://github.com/jlongster/prettier) as an eslint rule

This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect patterns in the AST. (If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors.) If your desired formatting does not match the `prettier` output (e.g. if you don't want semicolons), you should use a different tool such as [prettier-eslint](https://github.com/kentcdodds/prettier-eslint) instead.
This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect patterns in the AST. (If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors.) You can use [eslint-config-prettier](https://github.com/lydell/eslint-config-prettier) to disable all formatting-related ESLint rules. If your desired formatting does not match the `prettier` output (e.g. if you don't want semicolons), you should use a different tool such as [prettier-eslint](https://github.com/kentcdodds/prettier-eslint) instead.

@@ -67,0 +67,0 @@ ## Migrating to 2.0.0

@@ -5,3 +5,5 @@ /**

*/
'use strict';
// ------------------------------------------------------------------------------

@@ -23,3 +25,3 @@ // Requirements

'foo("bar");\n',
{ code: "foo('bar');\n", options: [ { singleQuote: true } ] }
{ code: "foo('bar');\n", options: [{ singleQuote: true }] }
],

@@ -26,0 +28,0 @@ invalid: [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc