Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/twelve-files-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atomicsmash/coding-standards": minor
---

Add beta flat config for ESLint
101 changes: 100 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

165 changes: 165 additions & 0 deletions packages/coding-standards/beta/eslint/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
const OFF = 0;
const WARN = 1;
const ERROR = 2;

import js from "@eslint/js";
import esLintComments from "@eslint-community/eslint-plugin-eslint-comments";
import { defineConfig } from "eslint/config";
import importPlugin from "eslint-plugin-import";
import { playwrightConfigs } from "eslint-plugin-playwright";
import reactPlugin from "eslint-plugin-react";
import reactHooksPlugin from "eslint-plugin-react-hooks";
import globals from "globals";
import tseslint from "typescript-eslint";

export const config = defineConfig([
{
files: [
"**/*.js",
"**/*.cjs",
"**/*.mjs",
"**/*.ts",
"**/*.cts",
"**/*.mts",
],
extends: [
js.configs.recommended,
esLintComments.configs.recommended,
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
importPlugin.flatConfigs.typescript,
],
plugins: {
"@typescript-eslint": tseslint.plugin,
import: importPlugin,
},
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
},
parser: tseslint.parser,
parserOptions: {
projectService: true,
},
},
rules: {
"no-case-declarations": [OFF],
"import/order": [
ERROR,
{
alphabetize: {
order: "asc",
},
groups: [
"type",
"builtin",
"external",
"internal",
"parent",
["sibling", "index"],
],
"newlines-between": "ignore",
pathGroups: [],
pathGroupsExcludedImportTypes: [],
},
],
"prefer-const": [ERROR],
"no-var": [ERROR],
"import/no-duplicates": WARN,
"eslint-comments/no-unused-disable": [ERROR],
"eslint-comments/require-description": [
ERROR,
{ ignore: ["eslint-enable"] },
],
"@typescript-eslint/naming-convention": [
ERROR,
{
selector: "variableLike",
format: ["camelCase", "PascalCase", "UPPER_CASE"],
leadingUnderscore: "allow",
},
{ selector: "function", format: ["camelCase", "PascalCase"] },
{ selector: "typeLike", format: ["PascalCase"] },
{
selector: "variable",
types: ["boolean"],
format: ["PascalCase"],
prefix: ["is", "should", "has", "can", "did", "will", "are"],
leadingUnderscore: "allow",
},
],
"@typescript-eslint/consistent-type-definitions": [ERROR, "type"],
"@typescript-eslint/non-nullable-type-assertion-style": OFF,
"@typescript-eslint/no-unused-vars": [
ERROR,
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
{
files: ["*.cjs"],
languageOptions: {
sourceType: "commonjs",
},
},
{
files: ["*.mjs"],
languageOptions: {
sourceType: "module",
},
},
{
files: ["**/*.test.*"],
rules: {
"@typescript-eslint/no-unused-vars": [OFF],
},
},
{
files: ["**/*.jsx", "**/*.tsx"],
extends: [
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat["jsx-runtime"],
reactHooksPlugin.configs.flat["recommended-latest"],
],
settings: {
react: {
version: "detect",
},
},
rules: {
"react-hooks/exhaustive-deps": [
WARN,
{
additionalHooks: "(useSelect|useSuspenseSelect)",
},
],
},
},
]);

export const playwrightConfig = defineConfig([
{
extends: [playwrightConfigs["flat/recommended"]],
rules: {
"playwright/expect-expect": [
ERROR,
{
assertFunctionNames: [
"playAudit", // This is the lighthouse playwright test, which contains threshold assertions.
],
},
],
},
},
]);
Loading
Loading