Skip to content

Commit

Permalink
chore: add prettier (#442)
Browse files Browse the repository at this point in the history
* chore: add prettier

* fix lint
  • Loading branch information
bmish authored Feb 10, 2024
1 parent 87890a3 commit 71d03e5
Show file tree
Hide file tree
Showing 86 changed files with 5,445 additions and 3,881 deletions.
17 changes: 10 additions & 7 deletions eslint-remote-tester.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
"l10n-tw/canvas-lms",
"rust-lang/crates.io",
"simonihmig/ember-responsive-image",
"videojs/video.js"
"videojs/video.js",
],

/** Extensions of files under scanning */
Expand All @@ -40,15 +40,18 @@ module.exports = {
rules: Object.fromEntries(
fs
.readdirSync(`${__dirname}/lib/rules`)
.map((filename) => `qunit/${basename(filename, extname(filename))}`)
.map((ruleName) => [ruleName, "error"])
.map(
(filename) =>
`qunit/${basename(filename, extname(filename))}`,
)
.map((ruleName) => [ruleName, "error"]),
),

overrides: [
{
files: ["*.ts", "*.mts", "*.cts"],
parser: "@typescript-eslint/parser"
}
]
}
parser: "@typescript-eslint/parser",
},
],
},
};
199 changes: 88 additions & 111 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,64 @@

const js = require("@eslint/js");
const { FlatCompat } = require("@eslint/eslintrc");
const eslintPluginMarkdown = require("eslint-plugin-markdown");
const eslintPluginEslintPluginAll = require("eslint-plugin-eslint-plugin/configs/all");
const eslintPluginMarkdown = require("eslint-plugin-markdown");
const globals = require("globals");

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
recommendedConfig: js.configs.recommended,
});

module.exports = [
...compat.extends(
"plugin:node/recommended",
"plugin:eslint-comments/recommended",
"plugin:unicorn/recommended"
"plugin:node/recommended",
"plugin:prettier/recommended",
"plugin:unicorn/recommended",
),

eslintPluginEslintPluginAll,

// Apply mocha config only to tests.
...compat.extends("plugin:mocha/recommended").map(config => ({ ...config,
files: ["tests/**/*.js"] })),
...compat
.extends("plugin:mocha/recommended")
.map((config) => ({ ...config, files: ["tests/**/*.js"] })),

{
languageOptions: {
"sourceType": "script",
"ecmaVersion": "latest",
"globals": globals.node
}
},
{
"rules":
{
"array-bracket-spacing": ["error", "never"],
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs"],
"camelcase": ["error", { "properties": "always" }],
"comma-dangle": ["error", "never"],
"comma-spacing": ["error", { "before": false,
"after": true }],
"comma-style": ["error", "last"],
"complexity": ["error", 10],
"computed-property-spacing": ["error", "never"],
sourceType: "script",
ecmaVersion: "latest",
globals: globals.node,
},
rules: {
camelcase: ["error", { properties: "always" }],
complexity: ["error", 10],
"consistent-return": "error",
"consistent-this": ["error", "self"],
"curly": ["error", "multi-line"],
curly: ["error", "multi-line"],
"default-case": "error",
"dot-location": ["error", "property"],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
eqeqeq: "error",
"func-style": ["error", "declaration"],
"guard-for-in": "error",
"indent": ["error", 4, { "SwitchCase": 1,
"VariableDeclarator": 1 }],
"key-spacing": ["error", { "beforeColon": false,
"afterColon": true }],
"keyword-spacing": ["error", { "before": true,
"after": true }],
"linebreak-style": ["error", "unix"],
"lines-around-comment": [
"error",
{
"beforeBlockComment": false,
"afterBlockComment": false,
"beforeLineComment": true,
"afterLineComment": false,
"allowBlockStart": true,
"allowBlockEnd": true,
"allowObjectStart": true,
"allowObjectEnd": true,
"allowArrayStart": true,
"allowArrayEnd": true
}
beforeBlockComment: false,
afterBlockComment: false,
beforeLineComment: true,
afterLineComment: false,
allowBlockStart: true,
allowBlockEnd: true,
allowObjectStart: true,
allowObjectEnd: true,
allowArrayStart: true,
allowArrayEnd: true,
},
],
"max-depth": ["error", 5],
"new-cap": ["error", { "newIsCap": true,
"capIsNew": true }],
"new-parens": "error",
"new-cap": ["error", { newIsCap: true, capIsNew: true }],
"no-array-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
Expand All @@ -102,10 +81,7 @@ module.exports = [
"no-ex-assign": "error",
"no-extend-native": "error",
"no-extra-boolean-cast": "error",
"no-extra-parens": "error",
"no-extra-semi": "error",
"no-fallthrough": "error",
"no-floating-decimal": "error",
"no-func-assign": "error",
"no-implied-eval": "error",
"no-invalid-regexp": "error",
Expand All @@ -115,10 +91,7 @@ module.exports = [
"no-lonely-if": "error",
"no-loop-func": "error",
"no-mixed-requires": "error",
"no-mixed-spaces-and-tabs": "error",
"no-multi-spaces": ["error", { "ignoreEOLComments": true }],
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-unsafe-negation": "error",
"no-nested-ternary": "error",
"no-new-func": "error",
Expand Down Expand Up @@ -156,54 +129,61 @@ module.exports = [
"no-useless-return": "error",
"no-var": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": ["error", { "consistent": true }],
"object-curly-spacing": ["error", "always"],
"object-property-newline": "error",
"operator-assignment": ["error", "always"],
"operator-linebreak": ["error", "after"],
"padded-blocks": ["error", "never"],
"prefer-const": "error",
"prefer-template": "error",
"quote-props": ["error", "consistent"],
"quotes": ["error", "double"],
"radix": "error",
"semi": ["error", "always"],
"semi-spacing": ["error", { "before": false,
"after": true }],
"space-before-blocks": ["error", "always"],
"space-before-function-paren": ["error", { "anonymous": "always",
"named": "never" }],
"space-in-parens": ["error", "never"],
"space-infix-ops": "error",
"space-unary-ops": ["error", { "words": true,
"nonwords": false }],
"spaced-comment": ["error", "always", { "exceptions": ["-"] }],
"strict": ["error", "global"],
"template-curly-spacing": ["error", "never"],
radix: "error",
"spaced-comment": ["error", "always", { exceptions: ["-"] }],
strict: ["error", "global"],
"use-isnan": "error",
"valid-jsdoc": ["error", {
"prefer": {
"return": "returns"
}
}],
"valid-jsdoc": [
"error",
{
prefer: {
return: "returns",
},
},
],
"valid-typeof": "error",
"wrap-iife": "error",
"yoda": ["error", "never"],
yoda: ["error", "never"],

// eslint-plugin-eslint-plugin
"eslint-plugin/meta-property-ordering": ["error", [
"type", "docs", "fixable", "messages", "schema", "deprecated", "replacedBy"
]],
"eslint-plugin/require-meta-docs-url": ["error", {
"pattern": "https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/{{name}}.md"
}],
"eslint-plugin/meta-property-ordering": [
"error",
[
"type",
"docs",
"fixable",
"messages",
"schema",
"deprecated",
"replacedBy",
],
],
"eslint-plugin/require-meta-docs-url": [
"error",
{
pattern:
"https://github.com/platinumazure/eslint-plugin-qunit/blob/master/docs/rules/{{name}}.md",
},
],

// eslint-plugin-node
"node/no-missing-require": ["error", {
"allowModules": ["@typescript-eslint/parser"]
}],
"node/no-missing-require": [
"error",
{
allowModules: ["@typescript-eslint/parser"],
},
],

// prettier
"prettier/prettier": [
"error",
{
tabWidth: 4,
},
],

// eslint-plugin-unicorn
"unicorn/consistent-function-scoping": "off",
Expand All @@ -214,35 +194,32 @@ module.exports = [
// eslint-disable-next-line no-warning-comments
"unicorn/prefer-at": "off", // TODO: enable once we raise Node requirement to v16.6.0
"unicorn/prefer-module": "off",
"unicorn/prevent-abbreviations": "off"
}
"unicorn/prevent-abbreviations": "off",
},
},
{
files: ["**/*.md"],
plugins: { markdown: eslintPluginMarkdown },
processor: "markdown/markdown"
processor: "markdown/markdown",
},
{
"files": ["**/*.md/*.js", "**/*.md/*.javascript"],
"languageOptions": {
"parserOptions": {
"sourceType": "module"
}
// Markdown code samples.
files: ["**/*.md/*.js", "**/*.md/*.javascript"],
languageOptions: {
parserOptions: {
sourceType: "module",
},
},
"rules": {
"brace-style": "off",
"eqeqeq": "off",
rules: {
eqeqeq: "off",
"guard-for-in": "off",
"no-constant-condition": "off",
"no-empty-function": "off",
"no-undef": "off",
"no-unused-expressions": "off",
"no-unused-vars": "off",
"no-var": "off",
"quotes": "off",
"space-before-function-paren": "off",
"strict": "off"
}
}
strict: "off",
},
},
];

14 changes: 7 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const pkg = require("./package.json");
module.exports = {
meta: {
name: pkg.name,
version: pkg.version
version: pkg.version,
},

rules: requireIndex(`${__dirname}/lib/rules`),
Expand All @@ -23,8 +23,8 @@ module.exports = {
recommended: {
description: [
"This configuration includes rules which I recommend to avoid QUnit runtime errors or incorrect behavior, some of which can be difficult to debug. Some of these rules also encourage best practices that help QUnit work better for you.",
"For ESLint `.eslintrc.js` legacy config, extend from `\"plugin:qunit/recommended\"`.",
"For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`."
'For ESLint `.eslintrc.js` legacy config, extend from `"plugin:qunit/recommended"`.',
"For ESLint `eslint.config.js` flat config, load from `require('eslint-plugin-qunit/configs/recommended')`.",
].join(" "),
plugins: ["qunit"],
rules: {
Expand Down Expand Up @@ -62,8 +62,8 @@ module.exports = {
"qunit/no-throws-string": "error",
"qunit/require-expect": "error",
"qunit/require-object-in-propequal": "error",
"qunit/resolve-async": "error"
}
}
}
"qunit/resolve-async": "error",
},
},
},
};
2 changes: 1 addition & 1 deletion lib/configs/recommended.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ const plugin = require("../../index.js");

module.exports = {
plugins: { qunit: plugin },
rules: plugin.configs.recommended.rules
rules: plugin.configs.recommended.rules,
};
Loading

0 comments on commit 71d03e5

Please sign in to comment.