Skip to content

Commit

Permalink
Re-enable running our eslint rules using ts-node (microsoft#159495)
Browse files Browse the repository at this point in the history
Resubmission of microsoft#157532 with the following changes:

- Use `eslint-plugin-local` instead of `yarn` link to run our plugins
- Move our plugins to a top level `.eslintplugin` dir (as required by `eslint-plugin-local`)
- Update all names to `local/`
  • Loading branch information
mjbvz authored Aug 30, 2022
1 parent 3e44e34 commit 5e92794
Show file tree
Hide file tree
Showing 60 changed files with 240 additions and 1,401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import * as eslint from 'eslint';
import { TSESTree } from '@typescript-eslint/experimental-utils';
import * as path from 'path';
import * as minimatch from 'minimatch';
import minimatch from 'minimatch';
import { createImportRuleListener } from './utils';

const REPO_ROOT = path.normalize(path.join(__dirname, '../../../'));
const REPO_ROOT = path.normalize(path.join(__dirname, '../'));

interface ConditionalPattern {
when?: 'hasBrowser' | 'hasNode' | 'test';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions .eslintplugin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const glob = require('glob');
const path = require('path');

require('ts-node').register({ experimentalResolver: true, transpileOnly: true });

// Re-export all .ts files as rules
const rules = {};
glob.sync(`${__dirname}/*.ts`).forEach((file) => {
rules[path.basename(file, '.ts')] = require(file);
});

exports.rules = rules;
26 changes: 26 additions & 0 deletions .eslintplugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es2020",
"lib": [
"ES2020"
],
"module": "commonjs",
"esModuleInterop": true,
"alwaysStrict": true,
"allowJs": true,
"strict": true,
"exactOptionalPropertyTypes": false,
"useUnknownInCatchVariables": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"newLine": "lf",
"noEmit": true
},
"include": [
"**/*.ts",
"**/*.js"
],
"exclude": [
"node_modules/**"
]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
43 changes: 22 additions & 21 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"plugins": [
"@typescript-eslint",
"jsdoc",
"header"
"header",
"local"
],
"rules": {
"constructor-super": "warn",
Expand Down Expand Up @@ -61,17 +62,17 @@
]
}
],
"code-no-unused-expressions": [
"local/code-no-unused-expressions": [
"warn",
{
"allowTernary": true
}
],
"code-translation-remind": "warn",
"code-no-nls-in-standalone-editor": "warn",
"code-no-standalone-editor": "warn",
"code-no-unexternalized-strings": "warn",
"code-layering": [
"local/code-translation-remind": "warn",
"local/code-no-nls-in-standalone-editor": "warn",
"local/code-no-standalone-editor": "warn",
"local/code-no-unexternalized-strings": "warn",
"local/code-layering": [
"warn",
{
"common": [],
Expand Down Expand Up @@ -122,8 +123,8 @@
"**/*.test.ts"
],
"rules": {
"code-no-test-only": "error",
"code-no-unexternalized-strings": "off"
"local/code-no-test-only": "error",
"local/code-no-unexternalized-strings": "off"
}
},
{
Expand All @@ -132,14 +133,14 @@
"**/vscode.proposed.*.d.ts"
],
"rules": {
"vscode-dts-create-func": "warn",
"vscode-dts-literal-or-types": "warn",
"vscode-dts-interface-naming": "warn",
"vscode-dts-cancellation": "warn",
"vscode-dts-use-thenable": "warn",
"vscode-dts-region-comments": "warn",
"vscode-dts-vscode-in-comments": "warn",
"vscode-dts-provider-naming": [
"local/vscode-dts-create-func": "warn",
"local/vscode-dts-literal-or-types": "warn",
"local/vscode-dts-interface-naming": "warn",
"local/vscode-dts-cancellation": "warn",
"local/vscode-dts-use-thenable": "warn",
"local/vscode-dts-region-comments": "warn",
"local/vscode-dts-vscode-in-comments": "warn",
"local/vscode-dts-provider-naming": [
"warn",
{
"allowed": [
Expand All @@ -154,7 +155,7 @@
]
}
],
"vscode-dts-event-naming": [
"local/vscode-dts-event-naming": [
"warn",
{
"allowed": [
Expand Down Expand Up @@ -200,8 +201,8 @@
"src/**/*.ts"
],
"rules": {
"code-no-look-behind-regex": "warn",
"code-import-patterns": [
"local/code-no-look-behind-regex": "warn",
"local/code-import-patterns": [
"warn",
{
// imports that are allowed in all files of layers:
Expand Down Expand Up @@ -576,7 +577,7 @@
"test/**/*.ts"
],
"rules": {
"code-import-patterns": [
"local/code-import-patterns": [
"warn",
{
"target": "test/smoke/**",
Expand Down
5 changes: 0 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
}
}
],
"eslint.options": {
"rulePaths": [
"./build/lib/eslint"
]
},
"typescript.tsdk": "node_modules/typescript/lib",
"npm.exclude": "**/extensions/**",
"npm.packageManager": "yarn",
Expand Down
3 changes: 1 addition & 2 deletions build/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ function eslint() {
.src(eslintFilter, { base: '.', follow: true, allowEmpty: true })
.pipe(
gulpeslint({
configFile: '.eslintrc.json',
rulePaths: ['./build/lib/eslint'],
configFile: '.eslintrc.json'
})
)
.pipe(gulpeslint.formatEach('compact'))
Expand Down
3 changes: 1 addition & 2 deletions build/hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ function hygiene(some, linting = true) {
.pipe(filter(eslintFilter))
.pipe(
gulpeslint({
configFile: '.eslintrc.json',
rulePaths: ['./build/lib/eslint'],
configFile: '.eslintrc.json'
})
)
.pipe(gulpeslint.formatEach('compact'))
Expand Down
199 changes: 0 additions & 199 deletions build/lib/eslint/code-import-patterns.js

This file was deleted.

Loading

0 comments on commit 5e92794

Please sign in to comment.