Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hieu-w committed Dec 16, 2024
1 parent e756076 commit d758b88
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 226 deletions.
5 changes: 1 addition & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"streetsidesoftware.code-spell-checker"
]
"recommendations": ["esbenp.prettier-vscode", "streetsidesoftware.code-spell-checker"]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"files.insertFinalNewline": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.defaultFormatter": "esbenp.prettier-vscode",
// "editor.formatOnSave": true,
"editor.formatOnSave": true,
"eslint.workingDirectories": [
{
"directory": "packages/*",
Expand Down
16 changes: 8 additions & 8 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import globals from 'globals';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from "globals";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default [
eslintPluginPrettierRecommended,
Expand All @@ -8,16 +8,16 @@ export default [
globals: {
...globals.node,
},
ecmaVersion: 'latest',
sourceType: 'module',
ecmaVersion: "latest",
sourceType: "module",
},

rules: {
'prettier/prettier': [
'error',
"prettier/prettier": [
"error",
{
singleQuote: true,
parser: 'flow',
singleQuote: false,
parser: "flow",
},
],
},
Expand Down
72 changes: 41 additions & 31 deletions packages/eslint-config-node/index.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,53 @@
import chaiExpectPlugin from 'eslint-plugin-chai-expect';
import chaiExpectPlugin from "eslint-plugin-chai-expect";
import nodePlugin from "eslint-plugin-n";
import pluginSecurity from 'eslint-plugin-security';
import pluginSecurity from "eslint-plugin-security";
import torusTypescriptConfig from "@toruslabs/eslint-config-typescript";
import globals from "globals";

export default [
...torusTypescriptConfig,
chaiExpectPlugin.configs["recommended-flat"],
nodePlugin.configs["flat/recommended-script"],
pluginSecurity.configs.recommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.commonjs,
...globals.es2020,
},
...torusTypescriptConfig,
chaiExpectPlugin.configs["recommended-flat"],
nodePlugin.configs["flat/recommended-script"],
pluginSecurity.configs.recommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.commonjs,
...globals.es2020,
},

ecmaVersion: 11,
sourceType: "module",
},
ecmaVersion: 11,
sourceType: "module",
},

rules: {
"import/extensions": ["error", "ignorePackages", {
js: "never",
ts: "never",
}],
rules: {
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
ts: "never",
},
],

"n/no-unsupported-features/es-syntax": ["error", {
version: ">=16",
ignores: ["modules"],
}],
"n/no-unsupported-features/es-syntax": [
"error",
{
version: ">=16",
ignores: ["modules"],
},
],

"n/no-missing-import": 0,
"n/no-missing-import": 0,

"import/no-extraneous-dependencies": ["error", {
devDependencies: ["**/*.test.ts", "**/*.test.tsx", "**/testHelpers.ts"],
}],
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.test.ts", "**/*.test.tsx", "**/testHelpers.ts"],
},
}
],
},
},
];
154 changes: 83 additions & 71 deletions packages/eslint-config-react/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,92 +14,104 @@ 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
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

/** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */
export default [
...fixupConfigRules(compat.extends(
"plugin:react-hooks/recommended",
)),
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
jsxA11Y.flatConfigs.recommended,
...torusTypescriptConfig,
{
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
"jsx-a11y": fixupPluginRules(jsxA11Y),
},
...fixupConfigRules(compat.extends("plugin:react-hooks/recommended")),
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat["jsx-runtime"],
jsxA11Y.flatConfigs.recommended,
...torusTypescriptConfig,
{
plugins: {
"react-hooks": fixupPluginRules(reactHooks),
"jsx-a11y": fixupPluginRules(jsxA11Y),
},

languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
...jsxA11Y.flatConfigs.recommended.languageOptions,
globals: {
...globals.browser,
...globals.node,
},
languageOptions: {
...reactPlugin.configs.flat.recommended.languageOptions,
...jsxA11Y.flatConfigs.recommended.languageOptions,
globals: {
...globals.browser,
...globals.node,
},

parser: tsParser,
ecmaVersion: 11,
sourceType: "module",
parser: tsParser,
ecmaVersion: 11,
sourceType: "module",

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},

settings: {
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
},
},
settings: {
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx", ".json"],
},
},
},

rules: {
"no-restricted-exports": 0,
"react/require-default-props": 0,
"tsdoc/syntax": 1,
rules: {
"no-restricted-exports": 0,
"react/require-default-props": 0,
"tsdoc/syntax": 1,

"@typescript-eslint/naming-convention": ["error", {
selector: "typeLike",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
}],
"@typescript-eslint/naming-convention": [
"error",
{
selector: "typeLike",
format: ["camelCase", "UPPER_CASE", "PascalCase"],
},
],

"@typescript-eslint/member-ordering": 1,
"import/prefer-default-export": 0,
"simple-import-sort/imports": 2,
"simple-import-sort/exports": 2,
"no-dupe-class-members": 0,
"@typescript-eslint/no-dupe-class-members": 2,
"no-useless-constructor": 0,
"@typescript-eslint/no-useless-constructor": 2,
"no-unused-vars": 0,
"@typescript-eslint/member-ordering": 1,
"import/prefer-default-export": 0,
"simple-import-sort/imports": 2,
"simple-import-sort/exports": 2,
"no-dupe-class-members": 0,
"@typescript-eslint/no-dupe-class-members": 2,
"no-useless-constructor": 0,
"@typescript-eslint/no-useless-constructor": 2,
"no-unused-vars": 0,

"@typescript-eslint/no-unused-vars": ["error", {
args: "after-used",
argsIgnorePattern: "_",
}],
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "after-used",
argsIgnorePattern: "_",
},
],

"import/extensions": ["error", "ignorePackages", {
js: "never",
ts: "never",
jsx: "never",
tsx: "never",
}],
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
ts: "never",
jsx: "never",
tsx: "never",
},
],

"no-console": 2,
"no-console": 2,

"prettier/prettier": [2, {
singleQuote: false,
printWidth: 150,
semi: true,
trailingComma: "es5",
}],
"prettier/prettier": [
2,
{
singleQuote: false,
printWidth: 150,
semi: true,
trailingComma: "es5",
},
}];
],
},
},
];
Loading

0 comments on commit d758b88

Please sign in to comment.