Skip to content

Commit

Permalink
Add @stylistic/eslint-plugin to ESLint configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Aug 31, 2024
1 parent 37bde15 commit caa46d0
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 14 deletions.
17 changes: 16 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import js from "@eslint/js";
import eslintPluginJsdoc from "eslint-plugin-jsdoc";
import eslintPluginNode from "eslint-plugin-n";
import eslintPluginStylistic from "@stylistic/eslint-plugin";
import eslintPluginUnicorn from "eslint-plugin-unicorn";

export default [
js.configs.all,
eslintPluginJsdoc.configs['flat/recommended'],
eslintPluginJsdoc.configs["flat/recommended"],
eslintPluginNode.configs["flat/recommended"],
eslintPluginStylistic.configs.customize({
"arrowParens": true,
"braceStyle": "1tbs",
"commaDangle": "never",
"jsx": false,
"quoteProps": "always",
"quotes": "double",
"semi": true
}),
eslintPluginUnicorn.configs["flat/all"],
{
"ignores": [
Expand Down Expand Up @@ -44,6 +54,11 @@ export default [
"sort-keys": "off",
"sort-imports": "off",

"@stylistic/array-bracket-spacing": [ "error", "always" ],
"@stylistic/dot-location": [ "error", "object" ],
"@stylistic/operator-linebreak": [ "error", "after", { "overrides": { "?": "before", ":": "before" } } ],
"@stylistic/padded-blocks": "off",

"unicorn/no-null": "off",
"unicorn/prefer-module": "off",
"unicorn/prefer-string-raw": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { createHash } = require("node:crypto");
* @param {string} violation The complete textual description of the violation.
* @returns {string} The SHA256 fingerprint for the violation as a hex string.
*/
const createFingerprint = function createFingerprint (violation) {
const createFingerprint = function createFingerprint(violation) {
const sha256 = createHash("sha256");
sha256.update(violation);
return sha256.digest("hex");
Expand All @@ -33,8 +33,8 @@ const outputFormatter = (options, params) => {
const column = (errorRange && errorRange[0]) || 0;
const columnText = column ? `:${column}` : "";
const description = ruleDescription +
(errorDetail ? ` [${errorDetail}]` : "") +
(errorContext ? ` [Context: "${errorContext}"]` : "");
(errorDetail ? ` [${errorDetail}]` : "") +
(errorContext ? ` [Context: "${errorContext}"]` : "");
// Construct error text with all details to use for unique fingerprint.
// Avoids duplicate fingerprints for the same violation on multiple lines.
const errorText =
Expand Down
4 changes: 2 additions & 2 deletions formatter-default/markdownlint-cli2-formatter-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const outputFormatter = (options) => {
errorContext, errorRange } = errorInfo;
const ruleName = ruleNames.join("/");
const description = ruleDescription +
(errorDetail ? ` [${errorDetail}]` : "") +
(errorContext ? ` [Context: "${errorContext}"]` : "");
(errorDetail ? ` [${errorDetail}]` : "") +
(errorContext ? ` [Context: "${errorContext}"]` : "");
const column = (errorRange && errorRange[0]) || 0;
const columnText = column ? `:${column}` : "";
logError(
Expand Down
12 changes: 6 additions & 6 deletions markdownlint-cli2.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const getAndProcessDirInfo = (
// Load markdownlint-cli2 object(s)
const markdownlintCli2Jsonc = pathPosix.join(dir, ".markdownlint-cli2.jsonc");
const markdownlintCli2Yaml = pathPosix.join(dir, ".markdownlint-cli2.yaml");
const markdownlintCli2Cjs = pathPosix.join(dir, ".markdownlint-cli2.cjs");
const markdownlintCli2Cjs = pathPosix.join(dir, ".markdownlint-cli2.cjs");
const markdownlintCli2Mjs = pathPosix.join(dir, ".markdownlint-cli2.mjs");
const packageJson = pathPosix.join(dir, "package.json");
let file = "[UNKNOWN]";
Expand Down Expand Up @@ -366,8 +366,8 @@ const getAndProcessDirInfo = (
then((config) => {
options.config = config;
});
})
.catch((error) => {
}).
catch((error) => {
throwForConfigurationFile(file, error);
})
);
Expand Down Expand Up @@ -1006,9 +1006,9 @@ const main = async (params) => {
// https://github.com/sindresorhus/globby/issues/265
(!params.fs && (baseMarkdownlintOptions.gitignore === true));
const ignoreFiles =
(!params.fs && (typeof baseMarkdownlintOptions.gitignore === "string")) ?
baseMarkdownlintOptions.gitignore :
undefined;
(!params.fs && (typeof baseMarkdownlintOptions.gitignore === "string"))
? baseMarkdownlintOptions.gitignore
: undefined;
const dirInfos =
await createDirInfos(
fs,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"devDependencies": {
"@eslint/js": "9.9.1",
"@iktakahiro/markdown-it-katex": "4.0.1",
"@stylistic/eslint-plugin": "2.7.2",
"ajv": "8.17.1",
"ava": "6.1.3",
"c8": "10.1.2",
Expand Down
2 changes: 1 addition & 1 deletion test/fs-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const mapPath = (base, mockPath) => {
};

class fsMock {
constructor (base, symbolicLinks) {
constructor(base, symbolicLinks) {
this.promises = {};
this.promises.access = (path, mode) => (
fs.promises.access(mapPath(base, path), mode)
Expand Down
2 changes: 1 addition & 1 deletion webworker/fs-virtual.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const dirent = (path, directory) => {

// eslint-disable-next-line no-unused-vars
class FsVirtual {
constructor (files) {
constructor(files) {

this.files = new Map(files);

Expand Down

0 comments on commit caa46d0

Please sign in to comment.