Skip to content

Commit

Permalink
fix(misc): resolve lint and test issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Sep 5, 2024
1 parent 7c03b1d commit c7e237e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 68 deletions.
9 changes: 8 additions & 1 deletion packages/eslint-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@
// Installed to workspace by plugins
"@typescript-eslint/parser",
"eslint-config-prettier",
"@angular-eslint/eslint-plugin"
"@angular-eslint/eslint-plugin",
"angular-eslint",
"typescript-eslint",
"@eslint/js",
"eslint-plugin-import",
"eslint-plugin-jsx-a11y",
"eslint-plugin-react",
"eslint-plugin-react-hooks"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ describe('@nx/eslint:lint-project', () => {
});

it('should generate a flat eslint base config', async () => {
const originalEslintUseFlatConfigVal = process.env.ESLINT_USE_FLAT_CONFIG;
process.env.ESLINT_USE_FLAT_CONFIG = 'true';
await lintProjectGenerator(tree, {
...defaultOptions,
linter: Linter.EsLint,
Expand Down Expand Up @@ -76,13 +78,13 @@ describe('@nx/eslint:lint-project', () => {
},
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// Add your rule overrides here
// Override or add rules here
rules: {},
},
];
"
`);
process.env.ESLINT_USE_FLAT_CONFIG = originalEslintUseFlatConfigVal;
});

it('should generate a eslint config (legacy)', async () => {
Expand Down
55 changes: 3 additions & 52 deletions packages/next/src/generators/application/lib/add-linting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,6 @@ describe('updateEslint', () => {
],
"rules": {},
},
{
"env": {
"jest": true,
},
"files": [
"*.spec.ts",
"*.spec.tsx",
"*.spec.js",
"*.spec.jsx",
],
},
],
}
`);
Expand All @@ -115,6 +104,7 @@ describe('updateEslint', () => {
.toMatchInlineSnapshot(`
"const { FlatCompat } = require("@eslint/eslintrc");
const js = require("@eslint/js");
const nx = require("@nx/eslint-plugin");
const baseConfig = require("../eslint.config.js");
const compat = new FlatCompat({
Expand All @@ -123,48 +113,9 @@ describe('updateEslint', () => {
});
module.exports = [
...compat.extends("plugin:@nx/react-typescript", "next", "next/core-web-vitals"),
...compat.extends("next", "next/core-web-vitals"),
...baseConfig,
{
"files": [
"**/*.ts",
"**/*.tsx",
"**/*.js",
"**/*.jsx"
],
"rules": {
"@next/next/no-html-link-for-pages": [
"error",
"my-app/pages"
]
}
},
{
files: [
"**/*.ts",
"**/*.tsx"
],
rules: {}
},
{
files: [
"**/*.js",
"**/*.jsx"
],
rules: {}
},
...compat.config({ env: { jest: true } }).map(config => ({
...config,
files: [
"**/*.spec.ts",
"**/*.spec.tsx",
"**/*.spec.js",
"**/*.spec.jsx"
],
rules: {
...config.rules
}
})),
...nx.configs["flat/react-typescript"],
{ ignores: [".next/**/*"] }
];
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,12 @@ exports[`lib should ignore test files in tsconfig.lib.json 1`] = `
`;

exports[`lib should support eslint flat config 1`] = `
"const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
"const vue = require('eslint-plugin-vue');
const baseConfig = require('../eslint.config.js');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});
module.exports = [
...compat.extends(
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/eslint-config-typescript',
'@vue/eslint-config-prettier/skip-formatting'
),
...baseConfig,
...vue.configs['flat/recommended'],
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue'],
rules: { 'vue/multi-word-component-names': 'off' },
Expand Down

0 comments on commit c7e237e

Please sign in to comment.