Skip to content

Commit

Permalink
Improve ESLint setup
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow committed Mar 26, 2024
1 parent 2fc42b9 commit f900c48
Show file tree
Hide file tree
Showing 37 changed files with 378 additions and 162 deletions.
16 changes: 16 additions & 0 deletions docs/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import baseConfig from '../eslint.config.js';

export default [
...baseConfig,
{
ignores: ['.vitepress/cache'],
},
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"dev": "vitepress dev",
"build": "del \"**/dist\" && vitepress build && cp _redirects .vitepress/dist",
"lint": "eslint \".vitepress/**/*.ts\"",
"preview": "vitepress preview"
},
"dependencies": {
Expand Down
8 changes: 8 additions & 0 deletions docs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"noEmit": true
},
"include": ["**/*.{js,ts}", ".vitepress/**/*.ts"],
"exclude": [".vitepress/cache"]
}
8 changes: 1 addition & 7 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{ ignores: ['**/dist/**/*', '**/test/**/*.js', '**/test/**/*.d.ts', './packages/utils/src/ansi.ts'] },
{ ignores: ['**/dist/', '**/node_modules/'] },
eslint.configs.recommended,
...tseslint.configs.strict,
{
languageOptions: {
parserOptions: {
project: ['./tsconfig.base.json', './docs/tsconfig.json', './packages/*/tsconfig.json'],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
'@typescript-eslint/no-dynamic-delete': 'off',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"build:examples": "pnpm run -r --parallel --if-present build:tokens",
"changeset": "changeset",
"dev": "pnpm run -r --parallel --if-present --filter \"@cobalt-ui/*\" dev",
"lint": "eslint \"packages/**/*.{ts,js,cjs,mjs}\"",
"lint": "pnpm run -r --parallel --if-present lint",
"test": "pnpm run -r --if-present --aggregate-output --parallel test",
"prepublishOnly": "pnpm run build",
"version": "pnpm run build && changeset version && pnpm i --no-frozen-lockfile"
Expand All @@ -22,10 +22,10 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.27.1",
"del-cli": "^5.1.0",
"eslint": "9.0.0-beta.2",
"eslint": "9.0.0-rc.0",
"js-yaml": "^4.1.0",
"prettier": "^3.2.5",
"typescript": "^5.4.2",
"typescript-eslint": "^7.2.0"
"typescript": "^5.4.3",
"typescript-eslint": "^7.4.0"
}
}
16 changes: 16 additions & 0 deletions packages/cli/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
ignores: ['**/test/fixtures/**/*'],
},
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts",
"build:clean": "del dist",
"build:ts": "tsc",
"dev": "tsc -w",
"build:ts": "tsc -p tsconfig.build.json",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
13 changes: 13 additions & 0 deletions packages/core/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts && pnpm run build:bundle && pnpm run build:license",
"build:clean": "del dist",
"build:ts": "tsc",
"build:ts": "tsc -p tsconfig.build.json",
"build:bundle": "esbuild --format=esm --bundle --minify dist/index.js --outfile=dist/index.min.js --sourcemap && cp dist/index.d.ts dist/index.min.d.ts",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/core dist/index.js,dist/index.min.js",
"dev": "pnpm run --parallel \"/^dev:.*/\"",
"dev:ts": "tsc --watch",
"lint": "eslint \"{src,test}/**/*\"",
"dev:ts": "tsc -p tsconfig.build.json --watch",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
13 changes: 13 additions & 0 deletions packages/lint-a11y/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
1 change: 1 addition & 0 deletions packages/lint-a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"build:ts": "tsc",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/plugin-css dist/index.js",
"dev": "tsc -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
2 changes: 1 addition & 1 deletion packages/lint-a11y/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
13 changes: 13 additions & 0 deletions packages/plugin-css/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/plugin-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts && pnpm run build:license",
"build:clean": "del dist",
"build:ts": "tsc",
"build:ts": "tsc -p tsconfig.build.json",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/plugin-css dist/index.js",
"dev": "tsc -w",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-css/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
3 changes: 1 addition & 2 deletions packages/plugin-css/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"],
"exclude": ["src/**/*.test.ts"]
"include": ["src", "test"]
}
16 changes: 16 additions & 0 deletions packages/plugin-js/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
ignores: ['**/actual.*', '**/want.*', '**/test/types/*'],
},
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/plugin-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts && pnpm run build:license",
"build:clean": "del dist",
"build:ts": "tsc",
"build:ts": "tsc -p tsconfig.build.json",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/plugin-js dist/index.js",
"dev": "tsc -w",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "co build -c ./test/types.tokens.mjs && pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-js/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/plugin-js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
13 changes: 13 additions & 0 deletions packages/plugin-sass/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/plugin-sass/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts && pnpm run build:license",
"build:clean": "del dist",
"build:ts": "tsc",
"build:ts": "tsc -p tsconfig.build.json",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/plugin-sass dist/index.js",
"dev": "tsc -w",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-sass/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/plugin-sass/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
16 changes: 16 additions & 0 deletions packages/plugin-tailwind/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
ignores: ['**/actual.*', '**/want.*'],
},
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/plugin-tailwind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
"scripts": {
"build": "pnpm run build:clean && pnpm run build:ts && pnpm run build:license",
"build:clean": "del dist",
"build:ts": "tsc",
"build:ts": "tsc -p tsconfig.build.json",
"build:license": "node ../../scripts/inject-license.js @cobalt-ui/plugin-tailwind dist/index.js",
"dev": "tsc -w",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "pnpm run \"/^test:.*/\"",
"test:js": "vitest run",
"test:ts": "tsc --noEmit"
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-tailwind/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/plugin-tailwind/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
13 changes: 13 additions & 0 deletions packages/utils/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import baseConfig from '../../eslint.config.js';

export default [
...baseConfig,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
];
5 changes: 3 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"type": "module",
"main": "./dist/index.js",
"scripts": {
"build": "del dist && tsc",
"dev": "tsc -w",
"build": "del dist && tsc -p tsconfig.build.json",
"dev": "tsc -p tsconfig.build.json -w",
"lint": "eslint \"{src,test}/**/*\"",
"test": "vitest run"
},
"devDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/utils/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["test"]
}
2 changes: 1 addition & 1 deletion packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"noEmit": false,
"outDir": "./dist/"
},
"include": ["src"]
"include": ["src", "test"]
}
Loading

0 comments on commit f900c48

Please sign in to comment.