diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 3c3629e64..000000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index fd85475da..000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "root": true, - "ignorePatterns": ["**/*"], - "plugins": ["@nx"], - "overrides": [ - { - "files": "*.json", - "parser": "jsonc-eslint-parser", - "rules": {} - }, - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": { - "@nx/enforce-module-boundaries": [ - "error", - { - "enforceBuildableLibDependency": true, - "allow": [], - "depConstraints": [ - { - "sourceTag": "*", - "onlyDependOnLibsWithTags": ["*"] - } - ] - } - ] - } - }, - { - "files": ["*.ts", "*.tsx"], - "extends": ["plugin:@nx/typescript"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "extends": ["plugin:@nx/javascript"], - "rules": {} - } - ] -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 000000000..f2e6e27cb --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,58 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const nxEslintPlugin = require("@nx/eslint-plugin"); +const typescriptConfig = require("@storm-software/linting-tools/eslint/typescript"); +const javascriptConfig = require("@storm-software/linting-tools/eslint/javascript"); +const graphqlConfig = require("@storm-software/linting-tools/eslint/graphql"); +const jestConfig = require("@storm-software/linting-tools/eslint/jest"); +const jsonConfig = require("@storm-software/linting-tools/eslint/json"); +const reactConfig = require("@storm-software/linting-tools/eslint/react"); +const nextConfig = require("@storm-software/linting-tools/eslint/next"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); + +module.exports = [ + { plugins: { "@nx": nxEslintPlugin } }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["**/*.json"], + rules: {} + })), + { + files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], + rules: { + "@nx/enforce-module-boundaries": [ + "error", + { + enforceBuildableLibDependency: true, + allow: [], + depConstraints: [ + { + sourceTag: "*", + onlyDependOnLibsWithTags: ["*"] + } + ] + } + ] + } + }, + ...compat.config({ extends: ["plugin:@nx/typescript"] }).map(config => ({ + ...config, + files: ["**/*.ts", "**/*.tsx"], + rules: {} + })), + ...compat.config({ extends: ["plugin:@nx/javascript"] }).map(config => ({ + ...config, + files: ["**/*.js", "**/*.jsx"], + rules: {} + })), + ...compat.config(typescriptConfig), + ...compat.config(javascriptConfig), + ...compat.config(graphqlConfig), + ...compat.config(jestConfig), + ...compat.config(jsonConfig), + ...compat.config(reactConfig), + ...compat.config(nextConfig) +]; diff --git a/package.json b/package.json index 2decde55a..c3a356aad 100644 --- a/package.json +++ b/package.json @@ -62,6 +62,7 @@ }, "prettier": "./dist/packages/linting-tools/prettier/config.json", "dependencies": { + "@eslint/eslintrc": "^2.1.1", "@nx/devkit": "17.0.3", "@nx/esbuild": "17.0.3", "@nx/eslint": "17.0.3", diff --git a/packages/create-storm-workspace/.eslintrc.json b/packages/create-storm-workspace/.eslintrc.json deleted file mode 100644 index 645ee3038..000000000 --- a/packages/create-storm-workspace/.eslintrc.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "parserOptions": { - "project": ["packages/create-storm-workspace/tsconfig.*?.json"] - }, - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": "error" - } - }, - { - "files": ["./package.json", "./generators.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/nx-plugin-checks": "error" - } - } - ] -} diff --git a/packages/create-storm-workspace/eslint.config.js b/packages/create-storm-workspace/eslint.config.js new file mode 100644 index 000000000..b02bd6cb8 --- /dev/null +++ b/packages/create-storm-workspace/eslint.config.js @@ -0,0 +1,49 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const baseConfig = require("../../eslint.config.js"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); +module.exports = [ + ...baseConfig, + { + files: [ + "packages/create-storm-workspace/**/*.ts", + "packages/create-storm-workspace/**/*.tsx", + "packages/create-storm-workspace/**/*.js", + "packages/create-storm-workspace/**/*.jsx" + ], + parserOptions: { + project: ["packages/create-storm-workspace/tsconfig.*?.json"] + }, + rules: {} + }, + { + files: [ + "packages/create-storm-workspace/**/*.ts", + "packages/create-storm-workspace/**/*.tsx" + ], + rules: {} + }, + { + files: [ + "packages/create-storm-workspace/**/*.js", + "packages/create-storm-workspace/**/*.jsx" + ], + rules: {} + }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["packages/create-storm-workspace/**/*.json"], + rules: { "@nx/dependency-checks": "error" } + })), + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: [ + "packages/create-storm-workspace/package.json", + "packages/create-storm-workspace/generators.json" + ], + rules: { "@nx/nx-plugin-checks": "error" } + })) +]; diff --git a/packages/git-tools/.eslintrc.json b/packages/git-tools/.eslintrc.json deleted file mode 100644 index 31c4c666f..000000000 --- a/packages/git-tools/.eslintrc.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "parserOptions": { - "project": ["packages/git-tools/tsconfig.*?.json"] - }, - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": [ - "error", - { - "ignoredFiles": ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"] - } - ] - } - } - ] -} diff --git a/packages/git-tools/eslint.config.js b/packages/git-tools/eslint.config.js new file mode 100644 index 000000000..c7bfc45ed --- /dev/null +++ b/packages/git-tools/eslint.config.js @@ -0,0 +1,38 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const baseConfig = require("../../eslint.config.js"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); +module.exports = [ + ...baseConfig, + { + files: [ + "packages/git-tools/**/*.ts", + "packages/git-tools/**/*.tsx", + "packages/git-tools/**/*.js", + "packages/git-tools/**/*.jsx" + ], + parserOptions: { project: ["packages/git-tools/tsconfig.*?.json"] }, + rules: {} + }, + { + files: ["packages/git-tools/**/*.ts", "packages/git-tools/**/*.tsx"], + rules: {} + }, + { + files: ["packages/git-tools/**/*.js", "packages/git-tools/**/*.jsx"], + rules: {} + }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["packages/git-tools/**/*.json"], + rules: { + "@nx/dependency-checks": [ + "error", + { ignoredFiles: ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"] } + ] + } + })) +]; diff --git a/packages/linting-tools/.eslintrc.json b/packages/linting-tools/.eslintrc.json deleted file mode 100644 index a70eee1fe..000000000 --- a/packages/linting-tools/.eslintrc.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "parserOptions": { - "project": ["packages/linting-tools/tsconfig.*?.json"] - }, - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": [ - "error", - { - "ignoredFiles": ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"] - } - ] - } - } - ] -} diff --git a/packages/linting-tools/eslint.config.js b/packages/linting-tools/eslint.config.js new file mode 100644 index 000000000..6515f0593 --- /dev/null +++ b/packages/linting-tools/eslint.config.js @@ -0,0 +1,44 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const baseConfig = require("../../eslint.config.js"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); +module.exports = [ + ...baseConfig, + { + files: [ + "packages/linting-tools/**/*.ts", + "packages/linting-tools/**/*.tsx", + "packages/linting-tools/**/*.js", + "packages/linting-tools/**/*.jsx" + ], + parserOptions: { project: ["packages/linting-tools/tsconfig.*?.json"] }, + rules: {} + }, + { + files: [ + "packages/linting-tools/**/*.ts", + "packages/linting-tools/**/*.tsx" + ], + rules: {} + }, + { + files: [ + "packages/linting-tools/**/*.js", + "packages/linting-tools/**/*.jsx" + ], + rules: {} + }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["packages/linting-tools/**/*.json"], + rules: { + "@nx/dependency-checks": [ + "error", + { ignoredFiles: ["{projectRoot}/esbuild.config.{js,ts,mjs,mts}"] } + ] + } + })) +]; diff --git a/packages/workspace-tools/.eslintrc.json b/packages/workspace-tools/.eslintrc.json deleted file mode 100644 index bef6bc9f5..000000000 --- a/packages/workspace-tools/.eslintrc.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "extends": ["../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "parserOptions": { - "project": ["packages/workspace-tools/tsconfig.*?.json"] - }, - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": "error" - } - }, - { - "files": ["./package.json", "./generators.json", "./executors.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/nx-plugin-checks": "error" - } - } - ] -} diff --git a/packages/workspace-tools/eslint.config.js b/packages/workspace-tools/eslint.config.js new file mode 100644 index 000000000..034327dd7 --- /dev/null +++ b/packages/workspace-tools/eslint.config.js @@ -0,0 +1,48 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const baseConfig = require("../../eslint.config.js"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); +module.exports = [ + ...baseConfig, + { + files: [ + "packages/workspace-tools/**/*.ts", + "packages/workspace-tools/**/*.tsx", + "packages/workspace-tools/**/*.js", + "packages/workspace-tools/**/*.jsx" + ], + parserOptions: { project: ["packages/workspace-tools/tsconfig.*?.json"] }, + rules: {} + }, + { + files: [ + "packages/workspace-tools/**/*.ts", + "packages/workspace-tools/**/*.tsx" + ], + rules: {} + }, + { + files: [ + "packages/workspace-tools/**/*.js", + "packages/workspace-tools/**/*.jsx" + ], + rules: {} + }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["packages/workspace-tools/**/*.json"], + rules: { "@nx/dependency-checks": "error" } + })), + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: [ + "packages/workspace-tools/package.json", + "packages/workspace-tools/generators.json", + "packages/workspace-tools/executors.json" + ], + rules: { "@nx/nx-plugin-checks": "error" } + })) +]; diff --git a/packages/workspace-tools/src/generators/preset/files/.eslintrc.json b/packages/workspace-tools/src/generators/preset/files/.eslintrc.json deleted file mode 100644 index a6273a453..000000000 --- a/packages/workspace-tools/src/generators/preset/files/.eslintrc.json +++ /dev/null @@ -1,123 +0,0 @@ -{ - "ignorePatterns": ["**/*", "**/node_modules/**"], - "plugins": ["@nx"], - "extends": [ - "@storm-software/linting-tools/eslint/typescript", - "@storm-software/linting-tools/eslint/javascript", - "@storm-software/linting-tools/eslint/graphql", - "@storm-software/linting-tools/eslint/react", - "@storm-software/linting-tools/eslint/next", - "@storm-software/linting-tools/eslint/json", - "@storm-software/linting-tools/eslint/jest" - ], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": { - "@nx/enforce-module-boundaries": [ - "error", - { - "enforceBuildableLibDependency": true, - "allow": [], - "depConstraints": [ - { - "sourceTag": "*", - "onlyDependOnLibsWithTags": ["*"] - }, - /** - * Platform type dependency rules - */ - { - "sourceTag": "platform:shared", - "onlyDependOnLibsWithTags": ["platform:shared"] - }, - { - "sourceTag": "platform:server", - "onlyDependOnLibsWithTags": [ - "platform:server", - "platform:shared" - ] - }, - { - "sourceTag": "platform:client", - "onlyDependOnLibsWithTags": [ - "platform:client", - "platform:shared" - ] - }, - { - "sourceTag": "platform:admin", - "onlyDependOnLibsWithTags": [ - "platform:admin", - "platform:client", - "platform:server", - "platform:shared" - ] - }, - /** - * Scope dependency rules - */ - { - "sourceTag": "scope:core", - "onlyDependOnLibsWithTags": ["scope:core"] - }, - { - "sourceTag": "scope:adapters", - "onlyDependOnLibsWithTags": ["scope:core", "scope:adapters"] - }, - { - "sourceTag": "scope:tools", - "onlyDependOnLibsWithTags": ["scope:core", "scope:tools"] - }, - { - "sourceTag": "scope:docs", - "onlyDependOnLibsWithTags": [ - "scope:core", - "scope:tools", - "scope:docs" - ] - }, - /** - * Domain Level dependency rules - */ - { - "sourceTag": "level:utilities", - "onlyDependOnLibsWithTags": ["level:utilities"] - }, - { - "sourceTag": "level:domain", - "onlyDependOnLibsWithTags": ["level:utilities", "level:domain"] - }, - { - "sourceTag": "level:application", - "onlyDependOnLibsWithTags": [ - "level:utilities", - "level:domain", - "level:application" - ] - }, - { - "sourceTag": "level:infrastructure", - "onlyDependOnLibsWithTags": [ - "level:utilities", - "level:domain", - "level:application", - "level:infrastructure" - ] - }, - { - "sourceTag": "level:application", - "onlyDependOnLibsWithTags": [ - "level:utilities", - "level:domain", - "level:application", - "level:infrastructure" - ] - } - ] - } - ] - } - } - ] -} diff --git a/packages/workspace-tools/src/generators/preset/files/eslint.config.js b/packages/workspace-tools/src/generators/preset/files/eslint.config.js new file mode 100644 index 000000000..f2e6e27cb --- /dev/null +++ b/packages/workspace-tools/src/generators/preset/files/eslint.config.js @@ -0,0 +1,58 @@ +const { FlatCompat } = require("@eslint/eslintrc"); +const nxEslintPlugin = require("@nx/eslint-plugin"); +const typescriptConfig = require("@storm-software/linting-tools/eslint/typescript"); +const javascriptConfig = require("@storm-software/linting-tools/eslint/javascript"); +const graphqlConfig = require("@storm-software/linting-tools/eslint/graphql"); +const jestConfig = require("@storm-software/linting-tools/eslint/jest"); +const jsonConfig = require("@storm-software/linting-tools/eslint/json"); +const reactConfig = require("@storm-software/linting-tools/eslint/react"); +const nextConfig = require("@storm-software/linting-tools/eslint/next"); +const js = require("@eslint/js"); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended +}); + +module.exports = [ + { plugins: { "@nx": nxEslintPlugin } }, + ...compat.config({ parser: "jsonc-eslint-parser" }).map(config => ({ + ...config, + files: ["**/*.json"], + rules: {} + })), + { + files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"], + rules: { + "@nx/enforce-module-boundaries": [ + "error", + { + enforceBuildableLibDependency: true, + allow: [], + depConstraints: [ + { + sourceTag: "*", + onlyDependOnLibsWithTags: ["*"] + } + ] + } + ] + } + }, + ...compat.config({ extends: ["plugin:@nx/typescript"] }).map(config => ({ + ...config, + files: ["**/*.ts", "**/*.tsx"], + rules: {} + })), + ...compat.config({ extends: ["plugin:@nx/javascript"] }).map(config => ({ + ...config, + files: ["**/*.js", "**/*.jsx"], + rules: {} + })), + ...compat.config(typescriptConfig), + ...compat.config(javascriptConfig), + ...compat.config(graphqlConfig), + ...compat.config(jestConfig), + ...compat.config(jsonConfig), + ...compat.config(reactConfig), + ...compat.config(nextConfig) +]; diff --git a/packages/workspace-tools/src/generators/preset/generator.ts b/packages/workspace-tools/src/generators/preset/generator.ts index 17f550e85..c2e734c83 100644 --- a/packages/workspace-tools/src/generators/preset/generator.ts +++ b/packages/workspace-tools/src/generators/preset/generator.ts @@ -214,6 +214,7 @@ export default async function (tree: Tree, options: PresetGeneratorSchema) { "prettier-plugin-prisma": "latest", "tsup": "latest", "eslint": "latest", + "@eslint/eslintrc": "latest", "log4brains": "latest", "husky": "latest", "prettier": "latest",