Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.eslintrc.js: Use trailingComma: "es5" with Prettier #3492

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
module.exports = {
env: {
es6: true,
node: true
node: true,
},
extends: ["eslint:recommended", "plugin:react/recommended"],
plugins: ["prettier", "react", "import"],
rules: {
curly: "error",
"import/no-extraneous-dependencies": [
"error",
{ devDependencies: ["tests*/**", "scripts/**"] }
{ devDependencies: ["tests*/**", "scripts/**"] },
],
"no-console": "off",
"no-else-return": "error",
Expand All @@ -26,11 +26,11 @@ module.exports = {
"react/no-deprecated": "off",
strict: "error",
"symbol-description": "error",
yoda: ["error", "never", { exceptRange: true }]
yoda: ["error", "never", { exceptRange: true }],
},
parserOptions: {
ecmaFeatures: {
jsx: true
}
}
jsx: true,
},
},
};
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
trailingComma: "es5",
}
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ prettier.format("lodash ( )", {
const ast = babylon(text);
ast.program.body[0].expression.callee.name = "_";
return ast;
}
},
});
// -> "_();\n"
```
Expand Down
26 changes: 13 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function formatWithCursor(text, opts, addAlignmentSize) {
const pragmas = Object.assign({ format: "" }, parsedDocblock.pragmas);
const newDocblock = docblock.print({
pragmas,
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, "") // remove leading newlines
comments: parsedDocblock.comments.replace(/^(\s+?\r?\n)+/, ""), // remove leading newlines
});
const strippedText = docblock.strip(text);
const separatingNewlines = strippedText.startsWith("\n") ? "\n" : "\n\n";
Expand Down Expand Up @@ -126,7 +126,7 @@ function formatWithCursor(text, opts, addAlignmentSize) {
if (cursorOffset !== undefined) {
return {
formatted: str,
cursorOffset: cursorOffsetResult + cursorOffset
cursorOffset: cursorOffsetResult + cursorOffset,
};
}

Expand All @@ -144,7 +144,7 @@ function findSiblingAncestors(startNodeAndParents, endNodeAndParents) {
if (resultStartNode === resultEndNode) {
return {
startNode: resultStartNode,
endNode: resultEndNode
endNode: resultEndNode,
};
}

Expand Down Expand Up @@ -174,7 +174,7 @@ function findSiblingAncestors(startNodeAndParents, endNodeAndParents) {

return {
startNode: resultStartNode,
endNode: resultEndNode
endNode: resultEndNode,
};
}

Expand All @@ -199,7 +199,7 @@ function findNodeAtOffset(node, offset, predicate, parentNodes) {
if (predicate(node)) {
return {
node: node,
parentNodes: parentNodes
parentNodes: parentNodes,
};
}
}
Expand Down Expand Up @@ -240,15 +240,15 @@ function isSourceElement(opts, node) {
"InterfaceDeclaration", // Flow, Typescript
"TypeAliasDeclaration", // Typescript
"ExportAssignment", // Typescript
"ExportDeclaration" // Typescript
"ExportDeclaration", // Typescript
];
const jsonSourceElements = [
"ObjectExpression",
"ArrayExpression",
"StringLiteral",
"NumericLiteral",
"BooleanLiteral",
"NullLiteral"
"NullLiteral",
];
const graphqlSourceElements = [
"OperationDefinition",
Expand All @@ -266,7 +266,7 @@ function isSourceElement(opts, node) {
"OperationTypeDefinition",
"InterfaceTypeDefinition",
"UnionTypeDefinition",
"ScalarTypeDefinition"
"ScalarTypeDefinition",
];
switch (opts.parser) {
case "flow":
Expand Down Expand Up @@ -310,7 +310,7 @@ function calculateRange(text, opts, ast) {
if (!startNodeAndParents || !endNodeAndParents) {
return {
rangeStart: 0,
rangeEnd: 0
rangeEnd: 0,
};
}

Expand All @@ -325,7 +325,7 @@ function calculateRange(text, opts, ast) {

return {
rangeStart: rangeStart,
rangeEnd: rangeEnd
rangeEnd: rangeEnd,
};
}

Expand Down Expand Up @@ -355,7 +355,7 @@ function formatRange(text, opts, ast) {
Object.assign({}, opts, {
rangeStart: 0,
rangeEnd: Infinity,
printWidth: opts.printWidth - alignmentSize
printWidth: opts.printWidth - alignmentSize,
}),
alignmentSize
);
Expand Down Expand Up @@ -421,6 +421,6 @@ module.exports = {
opts = normalizeOptions(opts);
const str = printDocToString(doc, opts);
return str;
}
}
},
},
};
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
coveragePathIgnorePatterns: [
"<rootDir>/src/doc-debug.js",
"<rootDir>/src/clean-ast.js",
"<rootDir>/src/deprecated.js"
"<rootDir>/src/deprecated.js",
],
transform: {}
transform: {},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"eslint": "4.1.1",
"eslint-friendly-formatter": "3.0.0",
"eslint-plugin-import": "2.6.1",
"eslint-plugin-prettier": "2.1.2",
"eslint-plugin-prettier": "2.3.1",
"eslint-plugin-react": "7.1.0",
"jest": "21.1.0",
"mkdirp": "0.5.1",
Expand Down
8 changes: 4 additions & 4 deletions scripts/build/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module.exports = {
{
files: "rollup.*.config.js",
parserOptions: {
sourceType: "module"
}
}
]
sourceType: "module",
},
},
],
};
2 changes: 1 addition & 1 deletion scripts/build/build-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const parsers = [
"graphql",
"postcss",
"parse5",
"markdown"
"markdown",
];

function pipe(string) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const parsers = [
"graphql",
"postcss",
"parse5",
"markdown"
"markdown",
];

process.env.PATH += path.delimiter + path.join(rootDir, "node_modules", ".bin");
Expand Down Expand Up @@ -96,7 +96,7 @@ const pkgWithoutDependencies = Object.assign({}, pkg);
delete pkgWithoutDependencies.dependencies;
pkgWithoutDependencies.scripts = {
prepublishOnly:
"node -e \"assert.equal(require('.').version, require('..').version)\""
"node -e \"assert.equal(require('.').version, require('..').version)\"",
};
pipe(JSON.stringify(pkgWithoutDependencies, null, 2)).to("dist/package.json");

Expand Down
4 changes: 2 additions & 2 deletions scripts/build/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export default {
"EVAL",
"MISSING_GLOBAL_NAME",
"MISSING_NODE_BUILTINS",
"UNRESOLVED_IMPORT"
"UNRESOLVED_IMPORT",
].find(code => code === warning.code)
) {
return;
}

console.warn(warning.message);
}
},
};
8 changes: 4 additions & 4 deletions scripts/build/rollup.bin.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default Object.assign(baseConfig, {
replace({ "#!/usr/bin/env node": "" }),
json(),
resolve({ preferBuiltins: true }),
commonjs()
commonjs(),
],
external: [
"fs",
Expand All @@ -24,9 +24,9 @@ export default Object.assign(baseConfig, {
"assert",
"util",
"events",
path.resolve("src/third-party.js")
path.resolve("src/third-party.js"),
],
paths: {
[path.resolve("src/third-party.js")]: "../third-party"
}
[path.resolve("src/third-party.js")]: "../third-party",
},
});
2 changes: 1 addition & 1 deletion scripts/build/rollup.docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export default Object.assign(baseConfig, {
plugins: [json(), resolve({ preferBuiltins: true }), commonjs(), globals()],
useStrict: false,
moduleName: basename.replace(/.+-/, ""),
external: ["assert", "fs", "module"]
external: ["assert", "fs", "module"],
});
8 changes: 4 additions & 4 deletions scripts/build/rollup.index.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ export default Object.assign(baseConfig, {
format: "cjs",
plugins: [
replace({
"process.env.NODE_ENV": JSON.stringify("production")
"process.env.NODE_ENV": JSON.stringify("production"),
}),
json(),
resolve({ preferBuiltins: true }),
commonjs()
commonjs(),
],
external,
paths: {
[path.resolve("src/third-party.js")]: "./third-party"
}
[path.resolve("src/third-party.js")]: "./third-party",
},
});
12 changes: 6 additions & 6 deletions scripts/build/rollup.parser.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default Object.assign(baseConfig, {
parser === "typescript"
? replace({
"exports.Syntax =": "1,",
include: "node_modules/typescript-eslint-parser/parser.js"
include: "node_modules/typescript-eslint-parser/parser.js",
})
: {},
// In flow-parser 0.59.0 there's a dynamic require: `require(s8)` which not
Expand All @@ -24,7 +24,7 @@ export default Object.assign(baseConfig, {
parser === "flow"
? replace({
"require(s8)": 'require("fs")',
include: "node_modules/flow-parser/flow_parser.js"
include: "node_modules/flow-parser/flow_parser.js",
})
: {},
json(),
Expand All @@ -37,8 +37,8 @@ export default Object.assign(baseConfig, {
throw result.error;
}
return result;
}
}
},
},
],
external: [
"fs",
Expand All @@ -48,7 +48,7 @@ export default Object.assign(baseConfig, {
"assert",
"util",
"os",
"crypto"
"crypto",
],
useStrict: parser !== "flow"
useStrict: parser !== "flow",
});
6 changes: 3 additions & 3 deletions scripts/build/rollup.third-party.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export default Object.assign(baseConfig, {
// with rollup the module is turned into a plain function located directly
// in index.js so `module.parent` does not exist. Defaulting to `module`
// instead seems to work.
"module.parent": "(module.parent || module)"
"module.parent": "(module.parent || module)",
}),
json(),
resolve({ preferBuiltins: true }),
commonjs()
commonjs(),
],
external: ["assert"]
external: ["assert"],
});
6 changes: 3 additions & 3 deletions scripts/run-external-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function tryFormat(file) {
// Allow specifying the parser via an environment variable:
parser: process.env.PARSER,
// Use file extension detection otherwise:
filepath: file
filepath: file,
});
} catch (error) {
return error;
Expand All @@ -30,7 +30,7 @@ function runExternalTests(patterns) {
const results = {
good: [],
skipped: [],
bad: []
bad: [],
};

testFiles.forEach(file => {
Expand Down Expand Up @@ -62,7 +62,7 @@ function run(argv) {
"Examples:",
' node scripts/run-external-tests.js "../TypeScript/tests/**/*.ts"',
' node scripts/run-external-tests.js "../flow/tests/**/*.js"',
' PARSER=flow node scripts/run-external-tests.js "../flow/tests/**/*.js"'
' PARSER=flow node scripts/run-external-tests.js "../flow/tests/**/*.js"',
].join("\n")
);
return 1;
Expand Down