Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

72 changes: 0 additions & 72 deletions .eslintrc.json

This file was deleted.

89 changes: 89 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import chaiExpect from "eslint-plugin-chai-expect";
import globals from "globals";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});

export default [{
ignores: ["test/**/*.importable.js"],
}, ...compat.extends("eslint:recommended"), {
plugins: {
"chai-expect": chaiExpect,
},

languageOptions: {
globals: {
...globals.node,
...globals.mocha,
expect: false,
},

ecmaVersion: 2018,
sourceType: "commonjs",

parserOptions: {
ecmaFeatures: {
jsx: false,
},
},
},

settings: {},

rules: {
curly: ["error", "all"],
"no-var": "error",

indent: ["error", 4, {
SwitchCase: 1,
}],

semi: ["error", "always"],
"object-curly-spacing": ["error", "always"],
"comma-dangle": ["error", "only-multiline"],

"space-before-function-paren": ["error", {
anonymous: "always",
named: "never",
asyncArrow: "always",
}],

"padding-line-between-statements": ["error", {
blankLine: "always",
prev: ["directive", "import", "const", "let", "block-like"],
next: "*",
}, {
blankLine: "always",
prev: "*",
next: ["export", "return", "throw", "block-like"],
}, {
blankLine: "any",
prev: "import",
next: "import",
}, {
blankLine: "any",
prev: "const",
next: "const",
}, {
blankLine: "any",
prev: "let",
next: "let",
}],

"padded-blocks": ["error", "never"],
"prefer-rest-params": "error",
"prefer-spread": "error",
"prefer-const": "error",
"chai-expect/terminating-properties": 1,
"no-unused-expressions": "off",
},
}];
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function generateSourceCode(options) {
text: options.source.script,
ast: generated.ast
});
} catch (e) {
} catch (e) { // eslint-disable-line no-unused-vars
const script = utils.escapeImportKeyword(options.source.script);

generated.ast = espree.parse(script, getAstDefaultOptions());
Expand Down
24 changes: 13 additions & 11 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,20 @@ const getCommentFromSourceCode = (node, sourceCode, {
let lastComment = null;

if (node) {
const comments = sourceCode.getComments(node);

if (useLeading && comments.leading && comments.leading.length > 0) {
const leadingCommentIndex = useFirst ? 0 : comments.leading.length - 1;

lastComment = comments.leading[leadingCommentIndex].value;
if (useLeading) {
const leadingComments = sourceCode.getCommentsBefore(node);
if (leadingComments && leadingComments.length > 0) {
const leadingCommentIndex = useFirst ? 0 : leadingComments.length - 1;
lastComment = leadingComments[leadingCommentIndex].value;
}
}

if (useTrailing && comments.trailing && comments.trailing.length > 0) {
const trailingCommentIndex = useFirst ? 0 : comments.trailing.length - 1;

lastComment = comments.trailing[trailingCommentIndex].value;
if (useTrailing) {
const trailingComments = sourceCode.getCommentsAfter(node);
if (trailingComments && trailingComments.length > 0) {
const trailingCommentIndex = useFirst ? 0 : trailingComments.length - 1;
lastComment = trailingComments[trailingCommentIndex].value;
}
}
}

Expand Down Expand Up @@ -494,7 +496,7 @@ const inferTypeFromVariableDeclaration = (variable) => {
}

return anyType;
} catch (error) {
} catch (error) { // eslint-disable-line no-unused-vars
return anyType;
}
};
Expand Down
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@
},
"homepage": "https://github.com/alexprey/sveltedoc-parser",
"dependencies": {
"espree": "9.2.0",
"eslint": "8.4.1",
"htmlparser2-svelte": "4.1.0"
"eslint": "^9.20.1",
"espree": "^9.2.0",
"htmlparser2-svelte": "^4.1.0"
},
"devDependencies": {
"@eslint/eslintrc": "3.2.0",
"@eslint/js": "9.20.0",
"chai": "4.1.2",
"dirty-chai": "2.0.1",
"eslint": "8.4.1",
"eslint-plugin-chai-expect": "3.0.0",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-chai-expect": "3.1.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"mocha": "9.1.3",
"glob": "7.2.0"
"eslint-plugin-promise": "7.2.1",
"glob": "7.2.0",
"globals": "15.15.0",
"mocha": "9.1.3"
},
"engines": {
"node": ">=10.0.0"
Expand Down
Loading