Skip to content

Commit

Permalink
chore: add prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
bmish committed Dec 9, 2023
1 parent bc854b0 commit bb67f27
Show file tree
Hide file tree
Showing 85 changed files with 5,435 additions and 3,872 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",
},
],
},
};
195 changes: 88 additions & 107 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,59 @@ 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: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
}
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"],
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 +82,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 +92,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 +130,53 @@ 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"],
},
],

// eslint-plugin-unicorn
"unicorn/consistent-function-scoping": "off",
Expand All @@ -214,35 +187,43 @@ 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"
}
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",
},
},

...compat.extends("plugin:prettier/recommended"),
{
rules: {
"prettier/prettier": [
"error",
{
tabWidth: 4,
},
],
},
},
];
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
// eslint-disable-next-line sort-keys
configs: {
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. You can use this configuration by extending from `\"plugin:qunit/recommended\"` in your configuration file.",
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. You can use this configuration by extending from `"plugin:qunit/recommended"` in your configuration file.',
plugins: ["qunit"],
rules: {
"qunit/assert-args": "error",
Expand Down Expand Up @@ -52,8 +53,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",
},
},
},
};

0 comments on commit bb67f27

Please sign in to comment.