Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0a2d8e0c
Unverified
Commit
0a2d8e0c
authored
Dec 17, 2019
by
Jonah Williams
Committed by
GitHub
Dec 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Remove direct usage of package:linter in the flutter_tools (#47174)
parent
117dfaf2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
15 deletions
+109
-15
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+89
-5
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+0
-10
create_config_test.dart
.../flutter_tools/test/general.shard/create_config_test.dart
+20
-0
No files found.
packages/flutter_tools/lib/src/commands/create.dart
View file @
0a2d8e0c
...
...
@@ -4,8 +4,7 @@
import
'dart:async'
;
import
'package:linter/src/rules/pub/package_names.dart'
as
package_names
;
// ignore: implementation_imports
import
'package:linter/src/utils.dart'
as
linter_utils
;
// ignore: implementation_imports
import
'package:meta/meta.dart'
;
import
'package:yaml/yaml.dart'
as
yaml
;
import
'../android/android.dart'
as
android
;
...
...
@@ -749,12 +748,97 @@ const Set<String> _packageDependencies = <String>{
'yaml'
,
};
// A valid Dart identifier.
// https://dart.dev/guides/language/language-tour#important-concepts
final
RegExp
_identifierRegExp
=
RegExp
(
'[a-zA-Z_][a-zA-Z0-9_]*'
);
// non-contextual dart keywords.
//' https://dart.dev/guides/language/language-tour#keywords
const
Set
<
String
>
_keywords
=
<
String
>{
'abstract'
,
'as'
,
'assert'
,
'async'
,
'await'
,
'break'
,
'case'
,
'catch'
,
'class'
,
'const'
,
'continue'
,
'covariant'
,
'default'
,
'deferred'
,
'do'
,
'dynamic'
,
'else'
,
'enum'
,
'export'
,
'extends'
,
'extension'
,
'external'
,
'factory'
,
'false'
,
'final'
,
'finally'
,
'for'
,
'function'
,
'get'
,
'hide'
,
'if'
,
'implements'
,
'import'
,
'in'
,
'inout'
,
'interface'
,
'is'
,
'late'
,
'library'
,
'mixin'
,
'native'
,
'new'
,
'null'
,
'of'
,
'on'
,
'operator'
,
'out'
,
'part'
,
'patch'
,
'required'
,
'rethrow'
,
'return'
,
'set'
,
'show'
,
'source'
,
'static'
,
'super'
,
'switch'
,
'sync'
,
'this'
,
'throw'
,
'true'
,
'try'
,
'typedef'
,
'var'
,
'void'
,
'while'
,
'with'
,
'yield'
,
};
/// Whether [name] is a valid Pub package.
@visibleForTesting
bool
isValidPackageName
(
String
name
)
{
final
Match
match
=
_identifierRegExp
.
matchAsPrefix
(
name
);
return
match
!=
null
&&
match
.
end
==
name
.
length
&&
!
_keywords
.
contains
(
name
);
}
/// Return null if the project name is legal. Return a validation message if
/// we should disallow the project name.
String
_validateProjectName
(
String
projectName
)
{
if
(!
linter_utils
.
isValidPackageName
(
projectName
))
{
final
String
packageNameDetails
=
package_names
.
PubPackageNames
().
details
;
return
'"
$projectName
" is not a valid Dart package name.
\n\n
$packageNameDetails
'
;
if
(!
isValidPackageName
(
projectName
))
{
return
'"
$projectName
" is not a valid Dart package name.
\n\n
'
'See https://dart.dev/tools/pub/pubspec#name for more information.
'
;
}
if
(
_packageDependencies
.
contains
(
projectName
))
{
return
"Invalid project name: '
$projectName
' - this will conflict with Flutter "
...
...
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
0a2d8e0c
...
...
@@ -1114,16 +1114,6 @@ void main() {
Pub:
()
=>
const
Pub
(),
});
testUsingContext
(
'fails when invalid package name'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
expect
(
runner
.
run
(<
String
>[
'create'
,
fs
.
path
.
join
(
projectDir
.
path
,
'invalidName'
)]),
throwsToolExit
(
message:
'"invalidName" is not a valid Dart package name.'
),
);
});
testUsingContext
(
'invokes pub offline when requested'
,
()
async
{
...
...
packages/flutter_tools/test/general.shard/create_config_test.dart
0 → 100644
View file @
0a2d8e0c
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_tools/src/commands/create.dart'
;
import
'../src/common.dart'
;
void
main
(
)
{
test
(
'Validates Pub package name'
,
()
{
expect
(
isValidPackageName
(
'is'
),
false
);
expect
(
isValidPackageName
(
'92'
),
false
);
expect
(
isValidPackageName
(
'a-b-c'
),
false
);
expect
(
isValidPackageName
(
'foo_bar'
),
true
);
expect
(
isValidPackageName
(
'_foo_bar'
),
true
);
expect
(
isValidPackageName
(
'fizz93'
),
true
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment